utils

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2022 License: BSD-2-Clause Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ReadOnlyPermissions = os.FileMode(0444)
	GeneratedFileSuffix = ".gr.go"
	ParsedSpecsFile     = "parsed-specs.gr.json"
)
View Source
const (
	Yes = ShouldUsePointer(0)
	No  = ShouldUsePointer(1)
)
View Source
const (
	MarshalRestLi              = "MarshalRestLi"
	UnmarshalRestLi            = "UnmarshalRestLi"
	EncodeQueryParams          = "EncodeQueryParams"
	PopulateLocalDefaultValues = "populateLocalDefaultValues"
	Equals                     = "Equals"
	ComputeHash                = "ComputeHash"
	ValidateUnionFields        = "ValidateUnionFields"
	ComplexKeyParamsField      = "Params"
	ComplexKeyParams           = "$params"
	FinderNameParam            = "q"

	RootPackage        = "github.com/PapaCharlie/go-restli"
	HashPackage        = RootPackage + "/fnv1a"
	RestLiPackage      = RootPackage + "/restli"
	RestLiCodecPackage = RootPackage + "/restlicodec"
	RestLiDataPackage  = RootPackage + "/restlidata"
	BatchKeySetPackage = RestLiPackage + "/batchkeyset"
	EqualsPackage      = RestLiPackage + "/equals"
)

Variables

View Source
var (
	Logger = log.New(os.Stderr, "[go-restli] ", log.LstdFlags|log.Lshortfile)

	PackagePrefix string

	HeaderTemplate = template.Must(template.New("header").Parse(`DO NOT EDIT

Code automatically generated by github.com/PapaCharlie/go-restli
Source file: {{.SourceFile}}`))
)
View Source
var (
	NewJsonReader  = Code(Qual(RestLiCodecPackage, "NewJsonReader"))
	RequiredFields = Code(Qual(RestLiCodecPackage, "RequiredFields"))

	BatchKeySet = Code(Id("set"))

	Hash     = Code(Qual(HashPackage, "Hash"))
	NewHash  = Code(Qual(HashPackage, "NewHash").Call())
	ZeroHash = Code(Qual(HashPackage, "ZeroHash").Call())

	IllegalEnumConstant = Code(Qual(RestLiPackage, "IllegalEnumConstant"))
	UnknownEnumValue    = Code(Qual(RestLiPackage, "UnknownEnumValue"))
)
View Source
var PagingContextIdentifier = Identifier{
	Name:      "PagingContext",
	Namespace: RestLiDataPackage,
}
View Source
var RawRecordContextIdentifier = Identifier{
	Name:      "RawRecord",
	Namespace: RestLiDataPackage,
}
View Source
var TypeRegistry = make(typeRegistry)

Functions

func AddFuncOnReceiver

func AddFuncOnReceiver(def *Statement, receiver, typeName, funcName string, pointer ShouldUsePointer) *Statement

func AddPointer added in v0.26.7

func AddPointer(def *Statement, receiver, typeName string) *Statement

func AddStringer

func AddStringer(def *Statement, receiver, typeName string, pointer ShouldUsePointer, f func(def *Group)) *Statement

func AddWordWrappedComment

func AddWordWrappedComment(code *Statement, comment string) *Statement

func CleanTargetDir added in v1.0.0

func CleanTargetDir(targetDir string) (err error)

func ExportedIdentifier

func ExportedIdentifier(identifier string) string

func FqcpToPackagePath

func FqcpToPackagePath(fqcp string) string

func IfErrReturn

func IfErrReturn(results ...Code) *Statement

func JsonFieldTag

func JsonFieldTag(name string, optional bool) map[string]string

func OrderedValues added in v1.0.0

func OrderedValues(f func(add func(key, value Code))) *Statement

func ReceiverName

func ReceiverName(typeName string) string

func WriteJenFile

func WriteJenFile(filename string, file *File) error

Types

type CodeFile

type CodeFile struct {
	SourceFile  string
	PackagePath string
	Filename    string
	Code        *Statement
}

func (*CodeFile) Identifier

func (f *CodeFile) Identifier() string

func (*CodeFile) Write

func (f *CodeFile) Write(outputDir string, writeInPackageDirs bool) (err error)

type ComplexType

type ComplexType interface {
	GetIdentifier() Identifier
	GetSourceFile() string
	InnerTypes() IdentifierSet
	ShouldReference() ShouldUsePointer
	GenerateCode() *jen.Statement
}

type Identifier

type Identifier struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

func (*Identifier) GetIdentifier

func (i *Identifier) GetIdentifier() Identifier

func (Identifier) PackagePath

func (i Identifier) PackagePath() string

func (Identifier) Qual

func (i Identifier) Qual() *jen.Statement

func (*Identifier) Receiver

func (i *Identifier) Receiver() string

func (*Identifier) Resolve

func (i *Identifier) Resolve() ComplexType

func (Identifier) String

func (i Identifier) String() string

type IdentifierSet

type IdentifierSet map[Identifier]bool

func NewIdentifierSet

func NewIdentifierSet(ids ...Identifier) IdentifierSet

func (IdentifierSet) Add

func (set IdentifierSet) Add(id Identifier) bool

func (IdentifierSet) AddAll

func (set IdentifierSet) AddAll(other IdentifierSet)

func (IdentifierSet) Get

func (set IdentifierSet) Get(id Identifier) bool

func (IdentifierSet) Remove

func (set IdentifierSet) Remove(id Identifier)

func (IdentifierSet) String

func (set IdentifierSet) String() string

type Path

type Path []Identifier

func (Path) Add

func (p Path) Add(id Identifier) Path

func (Path) IntroducesCycle

func (p Path) IntroducesCycle(nextNode Identifier) Path

func (Path) SeenNode

func (p Path) SeenNode(id Identifier) bool

type ShouldUsePointer added in v1.0.0

type ShouldUsePointer int

func (ShouldUsePointer) ShouldUsePointer added in v1.0.0

func (p ShouldUsePointer) ShouldUsePointer() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL