comptime

package
v0.89.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package comptime 提供了编译期相关的处理方式

go 以 //go:build 的方式区别编译内容,目前支持以下标签:

Index

Constants

View Source
const (
	Production  int = iota // 运行于生产环境
	Development            // 运行于开发环境
)
View Source
const Mode = defaultMode

Mode 当前的运行的环境

这是个编译期的常量,默认情况下始终是 Production, 只有在编译时指定了 development 标签才会为 Development

Variables

This section is empty.

Functions

func DebugRouter

func DebugRouter(r *web.Router, path, id string)

DebugRouter 在 Development 环境下为 r 提供一组测试用的 API

path 测试路径; id 在取地址参数出错时的 problem id;

func Filename

func Filename(f string) string

Filename 根据当前的环境生成不同的文件名

按以下规则返回文件名:

  • Production 原样返回;
  • Development 在扩展名前加上 _development,比如 file.yaml => file_development.yaml;

一般像根据环境加载不同的配置文件之类的功能可以使用此方法。 比如 server/app.CLI.ConfigFilename 可以使用此文件指定相同的文件名。

Types

This section is empty.

Jump to

Keyboard shortcuts

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