goio

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

go.io

framework interfaces and configurations for libraries

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version     string
	VersionFlag = flag.Bool("v", false, "version")

	HelpFlag = flag.Bool("h", false, "help")
)

Functions

func CreateToken added in v1.0.17

func CreateToken(appId string, openId string) (tokenStr string, err error)

func FlagInit added in v1.0.13

func FlagInit()

func Init added in v1.0.14

func Init(env Environment)

Types

type Environment added in v1.0.15

type Environment string
const (
	PRODUCTION  Environment = "pro"
	PRE         Environment = "pre"
	RT          Environment = "rt"
	TEST        Environment = "test"
	DEVELOPMENT Environment = "dev"
)

库运行模式 dev|test|rt|pre|pro go-zero

var Env Environment //string `json:",default=pro,options=dev|test|rt|pre|pro"`

当前运行环境

func (Environment) String added in v1.0.15

func (env Environment) String() string

func (Environment) Tag added in v1.0.15

func (env Environment) Tag() string

type OrderItem

type OrderItem struct {
	Column string `json:"column"`
	Asc    bool   `json:"asc"`
}

type Page

type Page struct {
	PageNo    int64        `json:"page_no,optional"`
	PageSize  int64        `json:"page_size,optional"`
	StartTime int64        `json:"start_time,optional"`
	EndTime   int64        `json:"end_time,optional"`
	SortBy    []*OrderItem `json:"sort_by,optional"`
}

type Response

type Response struct {
	Code int64       `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data,omitempty"`
}

func HttpBadRequest

func HttpBadRequest(msg string) *Response

请求格式错误,比如参数格式、参数字段名等 不正确

func HttpFail

func HttpFail(msg string) *Response

请求失败

func HttpFailForCode

func HttpFailForCode(code int64, msg string) *Response

如需返回特殊错误码,调用此接口

func HttpForbidden

func HttpForbidden(msg string) *Response

用户已进行身份认证,但权限不够

func HttpNotFound

func HttpNotFound(msg string) *Response

接口不存在

func HttpServerError

func HttpServerError(msg string) *Response

服务器内部错误

func HttpSuccess

func HttpSuccess(data interface{}) *Response

请求成功

func HttpSuccessByCode

func HttpSuccessByCode(code int64, data interface{}) *Response

func HttpUnauthorized

func HttpUnauthorized(msg string) *Response

用户没有访问权限,需要进行身份认证

type Token added in v1.0.17

type Token struct {
	AppId     string
	OpenId    string
	NonceStr  string
	Timestamp int64
}

生成 Token 验证Token

func ParseToken added in v1.0.17

func ParseToken(tokenStr, appId string) (token *Token, err error)

func (*Token) Bytes added in v1.0.17

func (t *Token) Bytes() []byte

func (*Token) String added in v1.0.17

func (t *Token) String() string

Jump to

Keyboard shortcuts

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