Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomConjureType ¶
type CustomConjureTypes ¶
type CustomConjureTypes interface { Add(name, pkg string, typer Typer) error Get(name string) (CustomConjureType, bool) }
func NewCustomConjureTypes ¶
func NewCustomConjureTypes() CustomConjureTypes
type PkgInfo ¶
type PkgInfo struct {
// contains filtered or unexported fields
}
func NewPkgInfo ¶
func NewPkgInfo(currPkgPath string, customTypes CustomConjureTypes) PkgInfo
func (*PkgInfo) AddImports ¶
AddImports adds imports to the internal mapping tracking import paths and package aliases in the event of conflicts. Typer.GoType uses this map to correctly build the selector for an imported declaration.
func (*PkgInfo) CustomTypes ¶
func (i *PkgInfo) CustomTypes() CustomConjureTypes
func (*PkgInfo) ImportAliases ¶
ImportAliases returns a copy of the map of import paths to aliases. Modifications to the returned map will not be written to the PkgInfo.
func (*PkgInfo) SetImports ¶
type Typer ¶
type Typer interface { // GoType returns the string that can be used as the Go type declaration for this type. currPkg and pkgAliases // are used to determine the import paths that should be used to qualify the usage of type names. If a type // occurs in a package that matches currPkg, the package will not be referenced. Otherwise, if the package path // matches a key in the pkgAliases map, the package name of the value (which is the last portion of its import // path) will be used. // // As an example, if type "t" is a type alias named "ExampleAlias" defined in "github.com/palantir/generated/alias": // // * t.GoType("github.com/palantir/generated/alias", nil) -> ExampleAlias // * t.GoType("github.com/project", nil) -> alias.ExampleAlias // * t.GoType("github.com/project", map[string]string{"github.com/palantir/generated/alias": "pkgalias" }) -> pkgalias.ExampleAlias GoType(info PkgInfo) string // ImportPath returns the strings that can be used as the Go import path for this type. Returns an empty string // if the type is a primitive and does not require an import. We must return a list for all collection types ImportPaths() []string }
var ( String Typer = &simpleType{ goType: "string", } Integer Typer = &simpleType{ goType: "int", } Double Typer = &simpleType{ goType: "float64", } Boolean Typer = &simpleType{ goType: "bool", } BinaryType Typer = &simpleType{ goType: "[]byte", } Any Typer = &simpleType{ goType: "interface{}", } IOReadCloserType Typer = &goType{ name: "ReadCloser", importPath: "io", } GetBodyType Typer = &funcType{ outputs: []Typer{ IOReadCloserType, }, } Bearertoken Typer = &goType{ name: "Token", importPath: "github.com/palantir/pkg/bearertoken", } BinaryPkg Typer = &goType{ name: "Binary", importPath: "github.com/palantir/pkg/binary", } DateTime Typer = &goType{ name: "DateTime", importPath: "github.com/palantir/pkg/datetime", } RID Typer = &goType{ name: "ResourceIdentifier", importPath: "github.com/palantir/pkg/rid", } SafeLong Typer = &goType{ name: "SafeLong", importPath: "github.com/palantir/pkg/safelong", } UUID Typer = &goType{ name: "UUID", importPath: "github.com/palantir/pkg/uuid", } ParseBool Typer = &goType{ name: "ParseBool", importPath: "strconv", } ParseFloat Typer = &goType{ name: "ParseFloat", importPath: "strconv", } ParseInt Typer = &goType{ name: "Atoi", importPath: "strconv", } ParseDateTime Typer = &goType{ name: "ParseDateTime", importPath: "github.com/palantir/pkg/datetime", } ParseRID Typer = &goType{ name: "ParseRID", importPath: "github.com/palantir/pkg/rid", } ParseSafeLong Typer = &goType{ name: "ParseSafeLong", importPath: "github.com/palantir/pkg/safelong", } ParseUUID Typer = &goType{ name: "ParseUUID", importPath: "github.com/palantir/pkg/uuid", } Base64Encoding Typer = &goType{ name: "StdEncoding", importPath: "encoding/base64", } CodecBinary Typer = &goType{ name: "Binary", importPath: "github.com/palantir/conjure-go-runtime/conjure-go-contract/codecs", } CodecJSON Typer = &goType{ name: "JSON", importPath: "github.com/palantir/conjure-go-runtime/conjure-go-contract/codecs", } SafeJSONMarshal Typer = &goType{ name: "Marshal", importPath: "github.com/palantir/pkg/safejson", } SafeJSONUnmarshal Typer = &goType{ name: "Unmarshal", importPath: "github.com/palantir/pkg/safejson", } )
func NewGoTypeFromExternalType ¶
func NewGoTypeFromExternalType(externalType spec.ExternalReference) (Typer, error)
func NewListType ¶
func NewMapType ¶
func NewOptionalType ¶
func NewSetType ¶
NewSetType creates a new Typer for a set type.
TODO: currently, sets and lists are treated identically. If we want to be more semantically precise, then the proper approach would be to define a Set as a map type with the provided key type and an empty struct as the value type. Because Go doesn't support generics, this would require generating a different Set type ("IntSet", "TestTypeSet", etc.) for each different set type that is required. This type would also need to implement custom JSON serialization and deserialization to translate to a JSON list, since that's the underlying representation required by the spec.