Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheFirst

func CacheFirst(objCache cache.ObjectCache, retrieveFunc RetrieveFunc) (string, error)

CacheFirst 缓存优先策略:先从缓存获取,失败则从源获取并缓存 注意: 缓存操作错误会被记录但不会阻断流程,保证服务的可用性

func CheckResult

func CheckResult(result Result, url string, request ...any) error

func Get

func Get[RESULT any](url string, request ...any) (RESULT, error)

func Post

func Post[RESULT any](url string, request ...any) (RESULT, error)

func PostResponse

func PostResponse(url string, request ...any) ([]byte, error)

PostResponse http post and get response 注意: 已添加超时设置

Types

type AccessTokenResult

type AccessTokenResult struct {
	Result
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type Result

type Result struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

type RetrieveFunc

type RetrieveFunc func() (string, int, error) // 返回值,过期时间

Jump to

Keyboard shortcuts

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