Golang mime.ParseMediaType() function example
package mime
Golang mime.ParseMediaType() function usage example
package main
import (
"fmt"
"mime"
"os"
)
func main() {
if len(os.Args) != 2 {
fmt.Printf("Usage : %s filename \n", os.Args[0])
os.Exit(1)
}
mType, parameters, err := mime.ParseMediaType(os.Args[1])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Media type : ", mType)
for param := range parameters {
fmt.Printf("%v = %v\n\n", param, parameters[param])
}
}
References :
https://www.socketloop.com/tutorials/golang-get-command-line-arguments
Advertisement
Something interesting
Tutorials
+8.4k Golang : Ackermann function example
+52.6k Golang : How to get struct field and value by name
+10.8k Android Studio : Checkbox for user to select options example
+12.8k Golang : http.Get example
+12.1k Golang : Sort and reverse sort a slice of runes
+9.6k Golang : How to generate Code 39 barcode?
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+6.4k Golang : Handling image beyond OpenCV video capture boundary
+10.8k Golang : Command line file upload program to server example
+6.1k Golang : Get missing location after unmarshal binary and gob decode time.
+13.8k Golang : Convert spaces to tabs and back to spaces example