package utilimport ()// IsJSONType method is to check JSON content type or notfunc ( string) bool {returnstrings.Contains(, "json")}// IsXMLType method is to check XML content type or notfunc ( string) bool {returnstrings.Contains(, "xml")}// GetPointer return the pointer of the interface.func ( any) any { := reflect.TypeOf()if .Kind() == reflect.Ptr {if := .Elem(); .Kind() == reflect.Ptr { // pointer of pointerif .Elem().Kind() == reflect.Ptr {panic("pointer of pointer of pointer is not supported") } := reflect.ValueOf().Elem()if .IsZero() { := reflect.New(.Elem()) .Set()return .Interface() } else {return .Interface() } } else {ifreflect.ValueOf().IsZero() { := reflect.New(.Elem())return .Interface() }return } }returnreflect.New().Interface()}// GetType return the underlying type.func ( any) reflect.Type {returnreflect.Indirect(reflect.ValueOf()).Type()}// CutString slices s around the first instance of sep,// returning the text before and after sep.// The found result reports whether sep appears in s.// If sep does not appear in s, cut returns s, "", false.func (, string) (, string, bool) {if := strings.Index(, ); >= 0 {return [:], [+len():], true }return , "", false}// CutBytes slices s around the first instance of sep,// returning the text before and after sep.// The found result reports whether sep appears in s.// If sep does not appear in s, cut returns s, nil, false.//// CutBytes returns slices of the original slice s, not copies.func (, []byte) (, []byte, bool) {if := bytes.Index(, ); >= 0 {return [:], [+len():], true }return , nil, false}// IsStringEmpty method tells whether given string is empty or notfunc ( string) bool {returnlen(strings.TrimSpace()) == 0}// See 2 (end of page 4) https://www.ietf.org/rfc/rfc2617.txt// "To receive authorization, the client sends the userid and password,// separated by a single colon (":") character, within a base64// encoded string in the credentials."// It is not meant to be urlencoded.func basicAuth(, string) string { := + ":" + returnbase64.StdEncoding.EncodeToString([]byte())}// BasicAuthHeaderValue return the header of basic auth.func (, string) string {return"Basic " + basicAuth(, )}// CreateDirectory create the directory.func ( string) ( error) {if _, = os.Stat(); != nil {ifos.IsNotExist() {if = os.MkdirAll(, 0755); != nil {return } } }return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.