utils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const GenerateBy = "// Code generated by gonectl. DO NOT EDIT."

Variables

This section is empty.

Functions

func Command

func Command(command string, args []string) error

func ExtractPackageArg

func ExtractPackageArg(args []string) string

ExtractPackageArg 从命令行参数中提取 package 参数

func FindFirstGoGenerateLine

func FindFirstGoGenerateLine(dir string) (targetPath string, targetNumber int, targetContent string, err error)

FindFirstGoGenerateLine 扫描目录,找到第一个匹配 //go:generate gonectl generate 的注释行

func FindGoModFile

func FindGoModFile(fromDir string) (string, error)

FindGoModFile 从指定目录向上逐层搜索 "go.mod" 文件

func GetExternalIP

func GetExternalIP() (string, error)

GetExternalIP 获取用户的外网 IP 地址

func GetGoneVersionFromModuleFile

func GetGoneVersionFromModuleFile(sanDir []string, scanFile []string) string

func IsIPInChina

func IsIPInChina(ip string) (bool, error)

IsIPInChina 通过 ip-api.com 检查 IP 是否在国内

func IsInChina

func IsInChina() bool

func ParseModuleName

func ParseModuleName(goModPath string) (string, error)

ParseModuleName 读取 go.mod 文件并解析出 module 名称

func TimeStat

func TimeStat(fn string) func()

Types

type ModuleInfo

type ModuleInfo struct {
	ModuleName string
	ModulePath string
}

func FindModuleInfo

func FindModuleInfo(dir string) (*ModuleInfo, error)

FindModuleInfo 获取当前目录所在的模块信息

Jump to

Keyboard shortcuts

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