Skip to content

Commit 14377b2

Browse files
authored
Merge pull request #3 from citizen233/master
feat: 解决golint警告、删除未使用函数、格式化代码
2 parents 85dce81 + 3396519 commit 14377b2

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
99
liberapay: # Replace with a single Liberapay username
1010
issuehunt: # Replace with a single IssueHunt username
1111
otechie: # Replace with a single Otechie username
12-
custom: ['https://pic2.zhimg.com/80/v2-6b84f07b309b6e1ad1b3141c3e9d34dc_1440w.png']
12+
custom: [ 'https://pic2.zhimg.com/80/v2-6b84f07b309b6e1ad1b3141c3e9d34dc_1440w.png' ]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A fast [dingding](https://ding-doc.dingtalk.com/) development sdk written in Gol
1010
```shell script
1111
go get github.com/fastwego/dingding
1212
```
13+
1314
```go
1415

1516
// 钉钉 AccessToken 管理器
@@ -41,15 +42,15 @@ resp, err := DingClient.Do(req)
4142

4243
[https://github.com/fastwego/dingding-demo](https://github.com/fastwego/dingding-demo)
4344

44-
4545
## 架构设计
4646

4747
![sdk](./doc/img/sdk.jpg)
4848

4949
## 框架特点
5050

5151
- 使用 Go 语言,开发快、编译快、部署快、运行快,轻松服务海量用户
52-
- 丰富的[文档](https://pkg.go.dev/github.com/fastwego/dingding)[演示代码](https://github.com/fastwego/dingding-demo) ,快速上手,5 分钟即可搭建一套完整的钉钉服务
52+
- 丰富的[文档](https://pkg.go.dev/github.com/fastwego/dingding)[演示代码](https://github.com/fastwego/dingding-demo) ,快速上手,5
53+
分钟即可搭建一套完整的钉钉服务
5354
- 独立清晰的模块划分,快速熟悉整个 sdk,没有意外,一切都是你期望的样子
5455
- 直接调用接口,最少封装,自由嵌入业务逻辑
5556
- 简单而强大的 AccessToken 管理:
@@ -63,7 +64,6 @@ resp, err := DingClient.Do(req)
6364
- 支持自定义 http.Client:
6465
- 默认使用 http.DefaultClient
6566

66-
6767
## 活跃的开发者社区
6868

6969
fastwego 是一套丰富的 Go 开发框架,支持钉钉、飞书、微信等服务,拥有庞大的开发者用户群体

access_token.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ import (
2727
"github.com/faabiosr/cachego"
2828
)
2929

30+
// AccessTokenManager 令牌管理器
3031
type AccessTokenManager interface {
3132
GetName() (name string)
3233
GetAccessToken() (accessToken string, err error)
3334
}
3435

3536
type getRefreshRequestFunc func() *http.Request
3637

38+
// DefaultAccessTokenManager 默认结构体
3739
type DefaultAccessTokenManager struct {
3840
Id string
3941
Name string
@@ -44,7 +46,7 @@ type DefaultAccessTokenManager struct {
4446
// 防止多个 goroutine 并发刷新冲突
4547
var getAccessTokenLock sync.Mutex
4648

47-
// GetAccessToken
49+
// GetAccessToken 从缓存里面获取 access_token ,没有就重新请求
4850
func (m *DefaultAccessTokenManager) GetAccessToken() (accessToken string, err error) {
4951

5052
cacheKey := m.getCacheKey()

client.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ const (
2828
contentTypeApplicationJson = "application/json"
2929
)
3030

31-
var (
32-
ServerUrl = "https://oapi.dingtalk.com"
33-
UserAgent = "fastwego/dingding"
34-
errorSystemBusy = errors.New("system busy")
35-
)
31+
// ServerUrl DingDing api接口地址
32+
var ServerUrl = "https://oapi.dingtalk.com"
33+
34+
// UserAgent 发送请求是,使用的用户标识
35+
var UserAgent = "fastwego/dingding"
36+
37+
var errorSystemBusy = errors.New("system busy")
3638

37-
// NewClient
39+
// NewClient 声明一个客户端
3840
func NewClient(AccessTokenManager AccessTokenManager) (client *Client) {
3941
return &Client{
4042
AccessTokenManager: AccessTokenManager,
4143
HttpClient: http.DefaultClient,
4244
}
4345
}
4446

45-
/*
46-
Client 用于向接口发送请求
47-
*/
47+
// Client 用于向接口发送请求
4848
type Client struct {
4949
AccessTokenManager AccessTokenManager
5050
HttpClient *http.Client

crypto.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/fastwego/dingding/util"
2727
)
2828

29+
// Crypto 加密结构体
2930
type Crypto struct {
3031
Token string
3132
EncodingAESKey string

dingding.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/*
16-
钉钉开发 SDK
15+
// 钉钉开发 SDK
16+
// See: https://ding-doc.dingtalk.com/
1717

18-
See: https://ding-doc.dingtalk.com/
19-
*/
2018
package dingding
2119

2220
import (
2321
"log"
2422
"os"
2523
)
2624

27-
// 日志记录器
25+
// Logger 日志记录器
2826
var Logger = log.New(os.Stdout, "[fastwego/dingding] ", log.LstdFlags|log.Llongfile)

util/signature.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010
)
1111

12+
// Signature 根据给定的内容和秘钥生成签名
1213
func Signature(data, secret string) string {
1314
h := hmac.New(sha256.New, []byte(secret))
1415
h.Write([]byte(fmt.Sprintf("%v\n%s", time.Now().UnixNano()/1e6, data)))

0 commit comments

Comments
 (0)