Documentation
¶
Index ¶
- Constants
- Variables
- func Config(path string, table ConfigBlock) map[string]any
- 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 HashAlgorithm(alg string) hash.Hash
- func ReadQRCode(filename string) (string, error)
- func Usage(s string) string
- type ByteSize
- type ConfigBlock
- type HTTPConfig
Constants ¶
View Source
const ( FileModeROwner os.FileMode = 0600 FileModeRAll os.FileMode = 0644 )
View Source
const ( HashMd5 = "md5" HashSha1 = "sha1" HashSha224 = "sha224" HashSha256 = "sha256" HashSha384 = "sha384" HashSha512 = "sha512" HashSha512_224 = "sha512_224" HashSha512_256 = "sha512_256" )
View Source
const ( IndentTwoSpaces = " " 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 Config ¶
func Config(path string, table ConfigBlock) map[string]any
Get secret token and other settings from config.
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 HashAlgorithm ¶
func ReadQRCode ¶ added in v0.1.7
Types ¶
type ConfigBlock ¶
type ConfigBlock string
Read config.
const ( Discord ConfigBlock = "discord" Encrypt ConfigBlock = "encrypt" ICP ConfigBlock = "west" LINE ConfigBlock = "line" Slack ConfigBlock = "slack" Telegram ConfigBlock = "telegram" )
func (ConfigBlock) String ¶
func (c ConfigBlock) String() string
Click to show internal directories.
Click to hide internal directories.