Skip to content

Commit b32e069

Browse files
author
Athurg Feng
committed
增加从环境变量中自动创建新客户端的方法
1 parent 261c3af commit b32e069

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package feidee
33
import (
44
"net/http"
55
"net/http/cookiejar"
6+
"os"
67
)
78

89
//请求的基础链接地址
@@ -68,3 +69,11 @@ func New(email, password string) (*Client, error) {
6869

6970
return cli, nil
7071
}
72+
73+
// 从环境变量中创建一个新客户端
74+
// 用户名、密码对应的环境变量分别为FEIDEE_USERNAME、FEIDEE_PASSWORD
75+
func NewFromEnv() (*Client, error) {
76+
username := os.Getenv("FEIDEE_USERNAME")
77+
password := os.Getenv("FEIDEE_PASSWORD")
78+
return New(username, password)
79+
}

0 commit comments

Comments
 (0)