util

package
v0.0.0-...-3ccaf53 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHttpBody

func BuildHttpBody(b interface{}) (*bytes.Buffer, error)

func Copy

func Copy(src, dest string) error

func EnsureDirectoryExists

func EnsureDirectoryExists(path string) error

func GenRandInt

func GenRandInt(min, max int) int

func GenerateAK

func GenerateAK(prefix string) (string, error)

GenerateAK 生成 Access Key (含前缀)

func GenerateSK

func GenerateSK() (string, error)

GenerateSK 生成 Secret Key (Base64)

func InSlice

func InSlice(s string, ss []string) bool

func IsDirectoryExists

func IsDirectoryExists(path string) bool

func IsFileExists

func IsFileExists(path string) bool

func KeyFunc

func KeyFunc(key interface{}) (int64, int64, error)

func Move

func Move(src, dest string) error

func NewHttpClient

func NewHttpClient(timeout time.Duration, url string) *httpClient

func ReadFromFile

func ReadFromFile(fileName string) ([]byte, error)

func RemoveFile

func RemoveFile(filePath string)

func RunCmd

func RunCmd(exec exec.Interface, cmd []string) ([]byte, error)

func ToRegexp

func ToRegexp(pattern string) string

func TrimAndFilter

func TrimAndFilter(input []string) []string

func WriteIntoFile

func WriteIntoFile(content string, fileName string) error

Types

type Auth

type Auth struct {
	Username string
	Password string
}

type Git

type Git struct {
	RepoDir string
	Branch  string
	Title   string
	// contains filtered or unexported fields
}

Git 封装 git 命令行,以避免依赖,golang 的 git 库需要按照 c 库

func NewGit

func NewGit(repoDir string, branch string, title string) *Git

func (*Git) Add

func (g *Git) Add() error

func (*Git) Checkout

func (g *Git) Checkout() error

func (*Git) Commit

func (g *Git) Commit() error

func (*Git) CurrentBranch

func (g *Git) CurrentBranch() (string, error)

func (*Git) LocalBranches

func (g *Git) LocalBranches() ([]string, error)

func (*Git) Push

func (g *Git) Push() error

type HttpClientV2

type HttpClientV2 struct {
	URL string
	// contains filtered or unexported fields
}

func (*HttpClientV2) Do

func (c *HttpClientV2) Do(val interface{}) *HttpError

func (*HttpClientV2) Method

func (c *HttpClientV2) Method(method string) *HttpClientV2

func (*HttpClientV2) WithAuth

func (c *HttpClientV2) WithAuth(username, password string) *HttpClientV2

func (*HttpClientV2) WithBody

func (c *HttpClientV2) WithBody(body io.Reader) *HttpClientV2

func (*HttpClientV2) WithFile

func (c *HttpClientV2) WithFile(filename string) *HttpClientV2

func (*HttpClientV2) WithHeader

func (c *HttpClientV2) WithHeader(headers map[string]string) *HttpClientV2

func (*HttpClientV2) WithTimeout

func (c *HttpClientV2) WithTimeout(t time.Duration) *HttpClientV2

type HttpError

type HttpError struct {
	Message string
	Code    int
	Err     error
}

func (HttpError) Error

func (h HttpError) Error() string

type HttpInterface

type HttpInterface interface {
	Post(url string, val interface{}, data interface{}, header map[string]string) error
	Put(url string, val interface{}, data map[string]interface{}) error
	Delete(url string, val interface{}) error
	Get(url string, val interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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