common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package common 一些公共数据的定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.2.0

type Config struct {
	AppID     string
	AppSecret string
	Host      string // 主机,不包含协议和端口
}

Config 微信的基本配置内容

func NewConfig added in v0.2.0

func NewConfig(appid, appsecret, host string) *Config

NewConfig 声明一个 Config 实例

Host 表示的微信的接口域名,留空,会选择通用的域名:api.weixin.qq.com 可参考说明

func (*Config) URL added in v0.2.0

func (c *Config) URL(urlpath string, queries map[string]string) string

URL 生成调用 api 的地址

根据 c.Host 不同,生成不同的地址。

type Result added in v0.2.0

type Result struct {
	Code    int    `json:"errcode,omitempty"`
	Message string `json:"errmsg,omitempty"`
}

Result 描述了微信和 http 状态码

其中 [0,400) 区间的为非错误代码; [400,600) 之间的为 HTTP 错误代码; [600,40000) 之间的自定义的错误代码; [40000,) 为微信的错误代码 NOTE: 当将 Result 当作一个 error 时,请确保 Result.IsOK() 为 false。

func From added in v0.2.0

func From(data []byte) *Result

From 将一段字符串转换成 Result 实例。

func NewResult added in v0.2.0

func NewResult(code int) *Result

NewResult 声明一个 Result 实例

func (*Result) Error added in v0.2.0

func (r *Result) Error() string

Error 实现 error 接口内容,在 IsOK 为 false 时,可以将 Result 当作一个 error 实例来使用。

func (*Result) IsOK added in v0.2.0

func (r *Result) IsOK() bool

IsOK 该结果是否正常返回

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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