data

package
v0.0.0-...-1970128 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const FunctionCode_ObjectToFormData = `` /* 869-byte string literal not displayed */
View Source
const MessageFileSuffix = ".go.ts"
View Source
const RequestMessageSuffix = "Req"
View Source
const ResponseMessageSuffix = "Res"
View Source
const ServiceFileSuffix = ".http.ts"

Variables

View Source
var Copyright = []byte("// Generate File, Should not Edit.\n" +
	"// Author: mario. https://github.com/mats9693\n" +
	"// Version: " + Version + "\n")
View Source
var MessageFieldType = map[string]string{
	"string": "string",
	"int32":  "number",
	"bool":   "boolean",
}

MessageFieldType go type - ts type

View Source
var MessageFieldZeroValue = map[string]string{
	"string":  `""`,
	"number":  `0`,
	"boolean": `false`,
}

MessageFieldZeroValue ts type - zero value

View Source
var Version = "goc_ts v0.2.1"

Functions

func FormatConfigCode

func FormatConfigCode(config *APIConfig) string

func FormatMessage

func FormatMessage(message *MessageItem) string

FormatMessage format 'message item' to ts code

func FormatServiceCode

func FormatServiceCode(serviceItems []*ServiceItem, messageItems []*MessageItem, filename string) string

func FuncCodeIndentation

func FuncCodeIndentation(funcCode string) string

func GetIndentation

func GetIndentation(level int) []byte

func SetIndentation

func SetIndentation(number int)

Types

type API

type API struct {
	Config  *APIConfig
	Utils   *APIUtils
	Service map[string][]*ServiceItem // filename - service items
	Message map[string][]*MessageItem // filename - message items
}

type APIConfig

type APIConfig struct {
	BaseURL string `json:"base_url"`
	Timeout int64  `json:"timeout"` // unit: micro-second
}

type APIUtils

type APIUtils struct {
	NeedObjectToFormData bool
	ObjectToFormData     []byte
}

type MessageField

type MessageField struct {
	Name        string // field name, from json tag of go struct field
	GoType      string
	TSType      string
	TSZeroValue string
	IsArray     bool
}

type MessageItem

type MessageItem struct {
	Name   string
	Fields []*MessageField
}

type ServiceItem

type ServiceItem struct {
	Name string
	URI  string
}

Jump to

Keyboard shortcuts

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