cmd/jwt/main.go
func buildEncArgs(args []string) ([]byte, error) {
	m := make(map[string]interface{})

	// loop over args, splitting on '=', and attempt parsing of value
	for _, arg := range args {
		a := strings.SplitN(arg, "=", 2)
		var val interface{}

		// attempt to parse
		if len(a) == 1 { // assume bool, set as true
			val = true
		} else if u, err := strconv.ParseUint(a[1], 10, 64); err == nil {
			val = u
		} else if i, err := strconv.ParseInt(a[1], 10, 64); err == nil {
			val = i
		} else if f, err := strconv.ParseFloat(a[1], 64); err == nil {
			val = f
		} else if b, err := strconv.ParseBool(a[1]); err == nil {
			val = b
		} else if s, err := strconv.Unquote(a[1]); err == nil {
			val = s
		} else { // treat as string
			val = a[1]
		}

		m[a[0]] = val
	}

	return json.Marshal(m)
}
func buildEncArgs(args []string) ([]byte, error) {
	m := make(map[string]interface{})

	// loop over args, splitting on '=', and attempt parsing of value
	for _, arg := range args {
		a := strings.SplitN(arg, "=", 2)
		var val interface{}

		// attempt to parse
		if len(a) == 1 { // assume bool, set as true
			val = true
		} else if u, err := strconv.ParseUint(a[1], 10, 64); err == nil {
			val = u
		} else if i, err := strconv.ParseInt(a[1], 10, 64); err == nil {
			val = i
		} else if f, err := strconv.ParseFloat(a[1], 64); err == nil {
			val = f
		} else if b, err := strconv.ParseBool(a[1]); err == nil {
			val = b
		} else if s, err := strconv.Unquote(a[1]); err == nil {
			val = s
		} else { // treat as string
			val = a[1]
		}

		m[a[0]] = val
	}

	return json.Marshal(m)
}
func buildEncArgs ( args [ ] string ) ( [ ] byte , error ) { m := make ( map [ string ] interface { } ) // loop over args, splitting on '=', and attempt parsing of value for _ , arg := range args { a := strings . SplitN ( arg , " " , 2 ) var val interface { } // attempt to parse if len ( a ) == 1 { // assume bool, set as true val = true } else if u , err := strconv . ParseUint ( a [ 1 ] , 10 , 64 ) ; err == nil { val = u } else if i , err := strconv . ParseInt ( a [ 1 ] , 10 , 64 ) ; err == nil { val = i } else if f , err := strconv . ParseFloat ( a [ 1 ] , 64 ) ; err == nil { val = f } else if b , err := strconv . ParseBool ( a [ 1 ] ) ; err == nil { val = b } else if s , err := strconv . Unquote ( a [ 1 ] ) ; err == nil { val = s } else { // treat as string val = a [ 1 ] } m [ a [ 0 ] ] = val } return json . Marshal ( m ) }
// buildEncArgs builds and encodes passed argument strings in the form of
// name=val as a json object.
buildEncArgs builds and encodes passed argument strings in the form of name = val as a json object .