Documentation ¶
Index ¶
- Constants
- Variables
- func ByteSize(i any) string
- func Config(path, table string) map[string]any
- func DefaultField(value any) zapcore.Field
- func Dos2Unix(filename string) error
- func Examples(example string, cmdName ...string) string
- func GenerateQRCode(content string, size int, dest string) error
- func HTTPRequestContent(url string, config ...HTTPConfig) ([]byte, error)
- func HTTPRequestContentGB18030(url string, body io.Reader, methods ...string) ([]byte, error)
- func HTTPRequestRedirectURL(uri string) (string, error)
- func IsCIDR(i string) bool
- func IsDarwin() bool
- func IsDomain(i any) bool
- func IsFile(f string) bool
- func IsIP(i string) bool
- func IsIPv4(i string) bool
- func IsIPv4CIDR(i string) bool
- func IsIPv6(i string) bool
- func IsIPv6CIDR(i string) bool
- func IsURL(u string) bool
- func IsWindows() bool
- func NewField(key string, value any) zapcore.Field
- func NewLogger() *zap.Logger
- func NewPrinter() *printer
- func ReadQRCode(filename string) (string, error)
- func SetLoggerLevel(level string)
- func SliceStringToInterface(s []string) []any
- func SliceStringToString(s []string, args ...string) string
- func SliceStringToStringNoSpaces(s []string, args ...string) string
- func StringRemoveSpaces(s string) string
- func Usage(s string) string
- type HTTPConfig
Constants ¶
View Source
const ( KiB byteSize = 1 << (10 * iota) MiB GiB TiB PiB EiB ZiB YiB )
View Source
const ( JSONFormat = "json" NoneFormat = "none" TableFormat = "table" TomlFormat = "toml" YamlFormat = "yaml" )
View Source
const ( RepoOwner = "linzeyan" RepoName = "ops-cli" UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" )
Variables ¶
View Source
var ( ErrConfigContent = errors.New("config content is incorrect") ErrConfigTable = errors.New("table not found in the config") ErrFailedInitial = errors.New("initial failed") ErrIllegalPath = errors.New("illegal file path") ErrInvalidArg = errors.New("invalid argument") ErrInvalidFlag = errors.New("required flag(s) not set") ErrInvalidIP = errors.New("invalid IP") ErrInvalidFile = errors.New("invalid file format") ErrInvalidToken = errors.New("invalid token") ErrInvalidURL = errors.New("invalid URL") ErrResponse = errors.New("response error") ErrStatusCode = errors.New("status code is not 200") )
View Source
var ( Context = context.Background() TimeNow = time.Now().Local() )
Functions ¶
func DefaultField ¶ added in v0.14.9
DefaultField calls zap.Any and gives key name "arg".
func GenerateQRCode ¶ added in v0.1.7
Generate QR code by giving content.
func HTTPRequestContent ¶
func HTTPRequestContent(url string, config ...HTTPConfig) ([]byte, error)
HttpRequestContent make a simple request to url, and return response body, default request method is get.
func HTTPRequestContentGB18030 ¶ added in v0.1.7
Same as HttpRequestContent, but read content in GB18030 format.
func HTTPRequestRedirectURL ¶ added in v0.1.7
Return redirect url.
func IsIPv4CIDR ¶ added in v0.14.5
func IsIPv6CIDR ¶ added in v0.14.5
func NewPrinter ¶ added in v0.14.4
func NewPrinter() *printer
func ReadQRCode ¶ added in v0.1.7
func SetLoggerLevel ¶ added in v0.14.8
func SetLoggerLevel(level string)
SetLoggerLevel set log level from given level.
func SliceStringToInterface ¶ added in v0.9.4
Return the slice interface from the given slice string.
func SliceStringToString ¶ added in v0.9.4
Return the string from the given slice.
func SliceStringToStringNoSpaces ¶ added in v0.11.5
Return the string without spaces from the given slice.
func StringRemoveSpaces ¶ added in v0.11.5
Return string without spaces from the given string.
Types ¶
Click to show internal directories.
Click to hide internal directories.