goio

package
v1.2.174 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

go.io

framework interfaces and configurations for libraries

package main

import (
	"github.com/gif-gif/go.io/goio"
	"github.com/gif-gif/go.io/goio/test/router"
)

func main() {
	startSever()
}

func startSever() {
	goio.Init(goio.DEVELOPMENT)
	s := goio.NewServer(
		goio.ServerNameOption("serverName"),
		goio.EnvOption(goio.Env),
		//goio.EnableEncryptionOption(),
		goio.PProfEnableOption(false),
		goio.NoLogPathsOption("/captcha/get"),
	)

	// 路由
	router.Routes(s.Group("/"))
	// 启动
	s.Run(":1000")
}
curl --location --request POST 'http://127.0.0.1:1000/health' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)'

Documentation

Index

Constants

View Source
const ERROR_DATABASE int64 = 555
View Source
const ERROR_FORBIDDEN int64 = 403
View Source
const ERROR_INVALID int64 = -1
View Source
const ERROR_NOTFOUND int64 = 404
View Source
const ERROR_PARAMS int64 = 700
View Source
const ERROR_REDIS int64 = 556
View Source
const ERROR_REQUEST int64 = 400

client

View Source
const ERROR_SERVER int64 = 500

server

View Source
const ERROR_UNAUTHORIZED int64 = 401
View Source
const SUCCESS_REQUEST = 0

Variables

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

	HelpFlag = flag.Bool("h", false, "help")
)
View Source
var (
	UnknownStatus = 0
	StatusValid   = 1
	StatusInValid = 2
)
View Source
var Name string

Functions

func FlagInit added in v1.0.13

func FlagInit()

func Init added in v1.0.14

func Init(env Environment, name ...string)

func Setup added in v1.2.147

func Setup(feishu string)

日志级别一键设置, 测试环境和生产环境发送飞书消息

也可以不用这个方法,项目中可以自定义, golog.WithHook 多次调用不会覆盖,每次调用都会生效

func SetupLogDefault added in v1.2.151

func SetupLogDefault()

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 = "dev" //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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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