import "github.com/appc/spec/schema/types" func validateName(name string) error { if err := types.ACName(name).Validate(); err != nil { return err } return nil }
import ( "encoding/json" "github.com/appc/spec/schema/types" ) type MyStruct struct { Name types.ACName `json:"name"` } func main() { s := MyStruct{types.ACName("myname")} data, _ := json.Marshal(s) fmt.Println(string(data)) // prints {"name":"myname"} }In this example, an `ACName` value is included as a field in a struct, and then that struct is marshalled to JSON using the `encoding/json` package. The resulting JSON includes a string value for the `Name` field that matches the original `ACName` value. Package library: `github.com/appc/spec/schema/types`