template

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FunctionJointForOpenAPI

func FunctionJointForOpenAPI(service string, functionPart []FunctionPart) string

FunctionJointForOpenAPI joint function part to a complete function special for api test.

func GetImportPkgName

func GetImportPkgName(root, module, path string) string

GetImportPkgName get the idl generated client package which will import to http client file.

func GetModule

func GetModule(root string) (string, error)

GetModule return module from go.mod in repo

func ProduceBaseFile

func ProduceBaseFile(path, pkg, service string, pkgImports []template.HTML) error

ProduceBaseFile generate client of specific service @param path string "path of generated file" @param pkg string "package name of go file" @param service string "service name" @param pkgImports []string "imported package list"

func ProducePath

func ProducePath(root string, client ClientInfo, service string) string

ProducePath returns the full path of generated file

func WriteFuncs

func WriteFuncs(path, funcs string) error

WriteFuncs write generated http function to give file.

Types

type ClientInfo

type ClientInfo struct {
	Group string // group which client belongs to
	Path  string // path which client.go will be generated
}

ClientInfo consist of group info and path to client.go

func GetClientInfo

func GetClientInfo(root string) []ClientInfo

GetClientInfo return idl generated client.go path, and get which group this client belongs to.

type FunctionPart

type FunctionPart struct {
	Action      string
	Request     string
	Response    string
	NewResponse string // struct name without pointer, used to create a new blank return struct.
}

FunctionPart consist of essential part to generate http api function.

func GetFuncPart

func GetFuncPart(filename string) (string, []FunctionPart, []template.HTML, error)

GetFuncPart get the service, Action, Request, Response and Response struct from idl generated function.

type Template

type Template struct {
	Package        string
	Service        string
	PackageImports []template.HTML
}

Template consist of message for generate basic http client.

Jump to

Keyboard shortcuts

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