snip

package
v6.41.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ByteReader          = jen.Qual("bytes", "NewReader").Clone
	Context             = jen.Qual("context", "Context").Clone
	ContextTODO         = jen.Qual("context", "TODO").Clone
	ContextBackground   = jen.Qual("context", "Background").Clone
	ContextVar          = jen.Id("ctx").Qual("context", "Context").Clone
	Base64NewDecoder    = jen.Qual("encoding/base64", "NewDecoder").Clone
	Base64StdEncoding   = jen.Qual("encoding/base64", "StdEncoding").Clone
	JSONMarshalIndent   = jen.Qual("encoding/json", "MarshalIndent").Clone
	FmtErrorf           = jen.Qual("fmt", "Errorf").Clone
	FmtPrintf           = jen.Qual("fmt", "Printf").Clone
	FmtFprintf          = jen.Qual("fmt", "Fprintf").Clone
	FmtSprint           = jen.Qual("fmt", "Sprint").Clone
	FmtSprintf          = jen.Qual("fmt", "Sprintf").Clone
	IOReadCloser        = jen.Qual("io", "ReadCloser").Clone
	IONopCloser         = jen.Qual("io", "NopCloser").Clone
	IOCopy              = jen.Qual("io", "Copy").Clone
	IODiscard           = jen.Qual("io", "Discard").Clone
	IOReader            = jen.Qual("io", "Reader").Clone
	JSONMarshaler       = jen.Qual("encoding/json", "Marshaler").Clone
	JSONUnmarshaler     = jen.Qual("encoding/json", "Unmarshaler").Clone
	MathIsInf           = jen.Qual("math", "IsInf").Clone
	MathIsNaN           = jen.Qual("math", "IsNaN").Clone
	MathInf             = jen.Qual("math", "Inf").Clone
	MathNaN             = jen.Qual("math", "NaN").Clone
	HTTPNoBody          = jen.Qual("net/http", "NoBody").Clone
	HTTPStatusNoContent = jen.Qual("net/http", "StatusNoContent").Clone
	HTTPRequest         = jen.Qual("net/http", "Request").Clone
	HTTPResponseWriter  = jen.Qual("net/http", "ResponseWriter").Clone
	URLPathEscape       = jen.Qual("net/url", "PathEscape").Clone
	URLValues           = jen.Qual("net/url", "Values").Clone
	OSStdin             = jen.Qual("os", "Stdin").Clone
	OSStdout            = jen.Qual("os", "Stdout").Clone
	OSReadFile          = jen.Qual("os", "ReadFile").Clone
	OSOpen              = jen.Qual("os", "Open").Clone
	ReflectTypeOf       = jen.Qual("reflect", "TypeOf").Clone
	StringsToUpper      = jen.Qual("strings", "ToUpper").Clone
	StringsHasPrefix    = jen.Qual("strings", "HasPrefix").Clone
	StringsTrimSpace    = jen.Qual("strings", "TrimSpace").Clone
	StrconvAppendFloat  = jen.Qual("strconv", "AppendFloat").Clone
	StrconvAppendInt    = jen.Qual("strconv", "AppendInt").Clone
	StrconvAtoi         = jen.Qual("strconv", "Atoi").Clone
	StrconvItoa         = jen.Qual("strconv", "Itoa").Clone
	StrconvParseBool    = jen.Qual("strconv", "ParseBool").Clone
	StrconvParseFloat   = jen.Qual("strconv", "ParseFloat").Clone
	StrconvQuote        = jen.Qual("strconv", "Quote").Clone
	FuncIOReadCloser    = jen.Func().Params().Params(IOReadCloser()).Clone // 'func() io.ReadCloser', the type of to http.Request.GetBody.

	CGRClientClient                     = jen.Qual(cgr+"conjure-go-client/httpclient", "Client").Clone
	CGRClientNewClient                  = jen.Qual(cgr+"conjure-go-client/httpclient", "NewClient").Clone
	CGRClientClientConfig               = jen.Qual(cgr+"conjure-go-client/httpclient", "ClientConfig").Clone
	CGRClientWithConfig                 = jen.Qual(cgr+"conjure-go-client/httpclient", "WithConfig").Clone
	CGRClientRequestParam               = jen.Qual(cgr+"conjure-go-client/httpclient", "RequestParam").Clone
	CGRClientTokenProvider              = jen.Qual(cgr+"conjure-go-client/httpclient", "TokenProvider").Clone
	CGRClientWithHeader                 = jen.Qual(cgr+"conjure-go-client/httpclient", "WithHeader").Clone
	CGRClientWithJSONRequest            = jen.Qual(cgr+"conjure-go-client/httpclient", "WithJSONRequest").Clone
	CGRClientWithJSONResponse           = jen.Qual(cgr+"conjure-go-client/httpclient", "WithJSONResponse").Clone
	CGRClientWithPathf                  = jen.Qual(cgr+"conjure-go-client/httpclient", "WithPathf").Clone
	CGRClientWithQueryValues            = jen.Qual(cgr+"conjure-go-client/httpclient", "WithQueryValues").Clone
	CGRClientWithRPCMethodName          = jen.Qual(cgr+"conjure-go-client/httpclient", "WithRPCMethodName").Clone
	CGRClientWithRawRequestBodyProvider = jen.Qual(cgr+"conjure-go-client/httpclient", "WithRawRequestBodyProvider").Clone
	CGRClientWithRawResponseBody        = jen.Qual(cgr+"conjure-go-client/httpclient", "WithRawResponseBody").Clone
	CGRClientWithRequiredResponse       = jen.Qual(cgr+"conjure-go-client/httpclient", "WithRequiredResponse").Clone
	CGRClientWithRequestMethod          = jen.Qual(cgr+"conjure-go-client/httpclient", "WithRequestMethod").Clone
	CGRClientWithRequestAppendFunc      = jen.Qual(cgr+"conjure-go-client/httpclient", "WithRequestAppendFunc").Clone
	CGRClientWithResponseUnmarshalFunc  = jen.Qual(cgr+"conjure-go-client/httpclient", "WithResponseUnmarshalFunc").Clone
	CGRCodecsBinary                     = jen.Qual(cgr+"conjure-go-contract/codecs", "Binary").Clone
	CGRCodecsJSON                       = jen.Qual(cgr+"conjure-go-contract/codecs", "JSON").Clone
	CGRErrorsPermissionDenied           = jen.Qual(cgr+"conjure-go-contract/errors", "PermissionDenied").Clone
	CGRErrorsInvalidArgument            = jen.Qual(cgr+"conjure-go-contract/errors", "InvalidArgument").Clone
	CGRErrorsNotFound                   = jen.Qual(cgr+"conjure-go-contract/errors", "NotFound").Clone
	CGRErrorsConflict                   = jen.Qual(cgr+"conjure-go-contract/errors", "Conflict").Clone
	CGRErrorsRequestEntityTooLarge      = jen.Qual(cgr+"conjure-go-contract/errors", "RequestEntityTooLarge").Clone
	CGRErrorsFailedPrecondition         = jen.Qual(cgr+"conjure-go-contract/errors", "FailedPrecondition").Clone
	CGRErrorsInternal                   = jen.Qual(cgr+"conjure-go-contract/errors", "Internal").Clone
	CGRErrorsTimeout                    = jen.Qual(cgr+"conjure-go-contract/errors", "Timeout").Clone
	CGRErrorsCustomClient               = jen.Qual(cgr+"conjure-go-contract/errors", "CustomClient").Clone
	CGRErrorsCustomServer               = jen.Qual(cgr+"conjure-go-contract/errors", "CustomServer").Clone
	CGRErrorsErrorCode                  = jen.Qual(cgr+"conjure-go-contract/errors", "ErrorCode").Clone
	CGRErrorsGetConjureError            = jen.Qual(cgr+"conjure-go-contract/errors", "GetConjureError").Clone
	CGRErrorsNewInternal                = jen.Qual(cgr+"conjure-go-contract/errors", "NewInternal").Clone
	CGRErrorsNewInvalidArgument         = jen.Qual(cgr+"conjure-go-contract/errors", "NewInvalidArgument").Clone
	CGRErrorsRegisterErrorType          = jen.Qual(cgr+"conjure-go-contract/errors", "RegisterErrorType").Clone
	CGRErrorsSerializableError          = jen.Qual(cgr+"conjure-go-contract/errors", "SerializableError").Clone
	CGRErrorsWrapWithInternal           = jen.Qual(cgr+"conjure-go-contract/errors", "WrapWithInternal").Clone
	CGRErrorsWrapWithInvalidArgument    = jen.Qual(cgr+"conjure-go-contract/errors", "WrapWithInvalidArgument").Clone
	CGRErrorsWrapWithPermissionDenied   = jen.Qual(cgr+"conjure-go-contract/errors", "WrapWithPermissionDenied").Clone
	CGRHTTPServerErrHandler             = jen.Qual(cgr+"conjure-go-server/httpserver", "ErrHandler").Clone
	CGRHTTPServerNewJSONHandler         = jen.Qual(cgr+"conjure-go-server/httpserver", "NewJSONHandler").Clone
	CGRHTTPServerParseBearerTokenHeader = jen.Qual(cgr+"conjure-go-server/httpserver", "ParseBearerTokenHeader").Clone
	CGRHTTPServerStatusCodeMapper       = jen.Qual(cgr+"conjure-go-server/httpserver", "StatusCodeMapper").Clone

	BinaryBinary                   = jen.Qual(pal+"pkg/binary", "Binary").Clone
	BinaryNew                      = jen.Qual(pal+"pkg/binary", "New").Clone
	BearerTokenNew                 = jen.Qual(pal+"pkg/bearertoken", "New").Clone
	BearerTokenToken               = jen.Qual(pal+"pkg/bearertoken", "Token").Clone
	BooleanBoolean                 = jen.Qual(pal+"pkg/boolean", "Boolean").Clone
	DateTimeDateTime               = jen.Qual(pal+"pkg/datetime", "DateTime").Clone
	DateTimeParseDateTime          = jen.Qual(pal+"pkg/datetime", "ParseDateTime").Clone
	RIDParseRID                    = jen.Qual(pal+"pkg/rid", "ParseRID").Clone
	RIDResourceIdentifier          = jen.Qual(pal+"pkg/rid", "ResourceIdentifier").Clone
	SafeLongNewSafeLong            = jen.Qual(pal+"pkg/safelong", "NewSafeLong").Clone
	SafeLongParseSafeLong          = jen.Qual(pal+"pkg/safelong", "ParseSafeLong").Clone
	SafeLongSafeLong               = jen.Qual(pal+"pkg/safelong", "SafeLong").Clone
	SafeJSONAppendFunc             = jen.Qual(pal+"pkg/safejson", "AppendFunc").Clone
	SafeJSONAppendQuotedString     = jen.Qual(pal+"pkg/safejson", "AppendQuotedString").Clone
	SafeJSONMarshal                = jen.Qual(pal+"pkg/safejson", "Marshal").Clone
	SafeJSONQuotedStringLength     = jen.Qual(pal+"pkg/safejson", "QuotedStringLength").Clone
	SafeJSONQuoteString            = jen.Qual(pal+"pkg/safejson", "QuoteString").Clone
	SafeJSONUnmarshal              = jen.Qual(pal+"pkg/safejson", "Unmarshal").Clone
	SafeYAMLJSONtoYAMLMapSlice     = jen.Qual(pal+"pkg/safeyaml", "JSONtoYAMLMapSlice").Clone
	SafeYAMLUnmarshalerToJSONBytes = jen.Qual(pal+"pkg/safeyaml", "UnmarshalerToJSONBytes").Clone
	UUIDUUID                       = jen.Qual(pal+"pkg/uuid", "UUID").Clone
	UUIDNewUUID                    = jen.Qual(pal+"pkg/uuid", "NewUUID").Clone
	UUIDParseUUID                  = jen.Qual(pal+"pkg/uuid", "ParseUUID").Clone

	WerrorErrorContext    = jen.Qual(pal+"witchcraft-go-error", "ErrorWithContextParams").Clone
	WerrorFormat          = jen.Qual(pal+"witchcraft-go-error", "Format").Clone
	WerrorNewStackTrace   = jen.Qual(pal+"witchcraft-go-error", "NewStackTrace").Clone
	WerrorParamsFromError = jen.Qual(pal+"witchcraft-go-error", "ParamsFromError").Clone
	WerrorSafeParam       = jen.Qual(pal+"witchcraft-go-error", "SafeParam").Clone
	WerrorStackTrace      = jen.Qual(pal+"witchcraft-go-error", "StackTrace").Clone
	WerrorUnsafeParam     = jen.Qual(pal+"witchcraft-go-error", "UnsafeParam").Clone
	WerrorWrap            = jen.Qual(pal+"witchcraft-go-error", "Wrap").Clone
	WerrorWrapContext     = jen.Qual(pal+"witchcraft-go-error", "WrapWithContextParams").Clone

	WGLLogSetDefaultLoggerProvider = jen.Qual(wgl+"wlog", "SetDefaultLoggerProvider").Clone
	WGLLogNoopLoggerProvider       = jen.Qual(wgl+"wlog", "NewNoopLoggerProvider").Clone
	WGLLogDebugLevel               = jen.Qual(wgl+"wlog", "DebugLevel").Clone
	WGLWlogZapLoggerProvider       = jen.Qual(wgl+"wlog-zap", "LoggerProvider").Clone
	WGLSvc1logWithLogger           = jen.Qual(wgl+"wlog/svclog/svc1log", "WithLogger").Clone
	WGLSvc1logNew                  = jen.Qual(wgl+"wlog/svclog/svc1log", "New").Clone
	WGLTrc1logWithLogger           = jen.Qual(wgl+"wlog/trclog/trc1log", "WithLogger").Clone
	WGLTrc1logNewLogger            = jen.Qual(wgl+"wlog/trclog/trc1log", "New").Clone
	WGLEvt2logWithLogger           = jen.Qual(wgl+"wlog/evtlog/evt2log", "WithLogger").Clone
	WGLEvt2logNew                  = jen.Qual(wgl+"wlog/evtlog/evt2log", "New").Clone
	WGTContextWithTracer           = jen.Qual(pal+"witchcraft-go-tracing/wtracing", "ContextWithTracer").Clone
	WGTZipkinNewTracer             = jen.Qual(pal+"witchcraft-go-tracing/wzipkin", "NewTracer").Clone

	WresourceNew                 = jen.Qual(wgs+"witchcraft/wresource", "New").Clone
	WrouterPathParams            = jen.Qual(wgs+"wrouter", "PathParams").Clone
	WrouterRouteParam            = jen.Qual(wgs+"wrouter", "RouteParam").Clone
	WrouterRouter                = jen.Qual(wgs+"wrouter", "Router").Clone
	WrouterForbiddenHeaderParams = jen.Qual(wgs+"wrouter", "ForbiddenHeaderParams").Clone
	WrouterForbiddenPathParams   = jen.Qual(wgs+"wrouter", "ForbiddenPathParams").Clone
	WrouterForbiddenQueryParams  = jen.Qual(wgs+"wrouter", "ForbiddenQueryParams").Clone
	WrouterSafeHeaderParams      = jen.Qual(wgs+"wrouter", "SafeHeaderParams").Clone
	WrouterSafePathParams        = jen.Qual(wgs+"wrouter", "SafePathParams").Clone
	WrouterSafeQueryParams       = jen.Qual(wgs+"wrouter", "SafeQueryParams").Clone

	GJSONNull       = jen.Qual("github.com/tidwall/gjson", "Null").Clone
	GJSONFalse      = jen.Qual("github.com/tidwall/gjson", "False").Clone
	GJSONNumber     = jen.Qual("github.com/tidwall/gjson", "Number").Clone
	GJSONString     = jen.Qual("github.com/tidwall/gjson", "String").Clone
	GJSONTrue       = jen.Qual("github.com/tidwall/gjson", "True").Clone
	GJSONJSON       = jen.Qual("github.com/tidwall/gjson", "JSON").Clone
	GJSONParse      = jen.Qual("github.com/tidwall/gjson", "Parse").Clone
	GJSONParseBytes = jen.Qual("github.com/tidwall/gjson", "ParseBytes").Clone
	GJSONResult     = jen.Qual("github.com/tidwall/gjson", "Result").Clone
	GJSONValid      = jen.Qual("github.com/tidwall/gjson", "Valid").Clone
	GJSONValidBytes = jen.Qual("github.com/tidwall/gjson", "ValidBytes").Clone

	TAny          = jen.Op("[").Id("T").Id("any").Op("]").Clone
	YamlUnmarshal = jen.Qual("gopkg.in/yaml.v3", "Unmarshal").Clone

	CobraCommand = jen.Qual("github.com/spf13/cobra", "Command").Clone

	PflagsFlagset = jen.Qual("github.com/spf13/pflag", "FlagSet").Clone
)

A set of imported references included in generated code. Each entry is a func() *jen.Statement, typically the Clone method. This ensures there are no side effects caused by mutating the global variables.

View Source
var DefaultImportsToPackageNames = map[string]string{
	cgr + "conjure-go-client/httpclient":   "httpclient",
	cgr + "conjure-go-contract/codecs":     "codecs",
	cgr + "conjure-go-contract/errors":     "errors",
	cgr + "conjure-go-server/httpserver":   "httpserver",
	pal + "pkg/binary":                     "binary",
	pal + "pkg/bearertoken":                "bearertoken",
	pal + "pkg/boolean":                    "boolean",
	pal + "pkg/datetime":                   "datetime",
	pal + "pkg/rid":                        "rid",
	pal + "pkg/safelong":                   "safelong",
	pal + "pkg/safejson":                   "safejson",
	pal + "pkg/safeyaml":                   "safeyaml",
	pal + "pkg/uuid":                       "uuid",
	pal + "witchcraft-go-error":            "werror",
	pal + "witchcraft-go-params":           "wparams",
	wgl + "wlog":                           "wlog",
	wgl + "wlog-zap":                       "wlogzap",
	wgl + "wlog/evtlog/evt2log":            "evt2log",
	wgl + "wlog/svclog/svc1log":            "svc1log",
	wgl + "wlog/trclog/trc1log":            "trc1log",
	pal + "witchcraft-go-tracing/wtracing": "wtracing",
	pal + "witchcraft-go-tracing/wzipkin":  "wzipkin",
	wgs + "witchcraft/wresource":           "wresource",
	wgs + "wrouter":                        "wrouter",
	"github.com/tidwall/gjson":             "gjson",
	"gopkg.in/yaml.v3":                     "yaml",
	"github.com/spf13/cobra":               "cobra",
}

Functions

func MethodAppendJSON

func MethodAppendJSON(receiverName, receiverType string) *jen.Statement

MethodAppendJSON returns 'func (o Foo) AppendJSON(out []byte) ([]byte, error)'

func MethodJSONSize

func MethodJSONSize(receiverName, receiverType string) *jen.Statement

MethodJSONSize returns 'func (o Foo) JSONSize() (int, error)'

func MethodMarshalJSON

func MethodMarshalJSON(receiverName, receiverType string) *jen.Statement

MethodMarshalJSON returns 'func (o Foo) MarshalJSON() ([]byte, error)'

func MethodMarshalText

func MethodMarshalText(receiverName, receiverType string) *jen.Statement

MethodMarshalText returns 'func (o Foo) MarshalText() ([]byte, error)'

func MethodMarshalYAML

func MethodMarshalYAML(receiverName, receiverType string) *jen.Statement

MethodMarshalYAML returns:

func (o Foo) MarshalYAML() (interface{}, error) {
	jsonBytes, err := safejson.Marshal(o)
	if err != nil {
		return nil, err
	}
	return safeyaml.JSONtoYAMLMapSlice(jsonBytes)
}

func MethodString

func MethodString(receiverName, receiverType string) *jen.Statement

MethodString returns 'func (o Foo) String() string'

func MethodUnmarshalJSON

func MethodUnmarshalJSON(receiverName, receiverType string) *jen.Statement

MethodUnmarshalJSON returns 'func (o *Foo) UnmarshalJSON(data []byte) error'

func MethodUnmarshalJSONStrict

func MethodUnmarshalJSONStrict(receiverName, receiverType string) *jen.Statement

MethodUnmarshalJSONStrict returns 'func (o *Foo) UnmarshalJSONStrict(data []byte) error'

func MethodUnmarshalString

func MethodUnmarshalString(receiverName, receiverType string) *jen.Statement

MethodUnmarshalString returns 'func (o *Foo) UnmarshalString(data string) error'

func MethodUnmarshalText

func MethodUnmarshalText(receiverName, receiverType string) *jen.Statement

MethodUnmarshalText returns 'func (o *Foo) UnmarshalText(data []byte) error'

func MethodUnmarshalYAML

func MethodUnmarshalYAML(receiverName, receiverType string) *jen.Statement

MethodUnmarshalYAML returns:

 func (o *Foo) UnmarshalYAML(unmarshal func(interface{}) error) error {
   jsonBytes, err := safeyaml.UnmarshalerToJSONBytes(unmarshal)
   if err != nil {
     return err
	  }
	  return safejson.Unmarshal(jsonBytes, *&o)
 }

Types

This section is empty.

Jump to

Keyboard shortcuts

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