mirror of
https://github.com/eiblog/eiblog.git
synced 2026-03-01 00:34:58 +08:00
use go1.11 with go mod
This commit is contained in:
30
vendor/github.com/qiniu/api.v7/conf/conf.go
generated
vendored
30
vendor/github.com/qiniu/api.v7/conf/conf.go
generated
vendored
@@ -1,30 +0,0 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/qiniu/x/ctype.v7"
|
||||
"github.com/qiniu/x/rpc.v7"
|
||||
)
|
||||
|
||||
var version = "7.2.3"
|
||||
|
||||
const (
|
||||
ctypeAppName = ctype.ALPHA | ctype.DIGIT | ctype.UNDERLINE | ctype.SPACE_BAR | ctype.SUB | ctype.DOT
|
||||
)
|
||||
|
||||
// userApp should be [A-Za-z0-9_\ \-\.]*
|
||||
func SetAppName(userApp string) error {
|
||||
if userApp != "" && !ctype.IsType(ctypeAppName, userApp) {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
rpc.UserAgent = fmt.Sprintf(
|
||||
"QiniuGo/%s (%s; %s; %s) %s", version, runtime.GOOS, runtime.GOARCH, userApp, runtime.Version())
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
SetAppName("")
|
||||
}
|
||||
35
vendor/github.com/qiniu/api.v7/conf/conf_test.go
generated
vendored
35
vendor/github.com/qiniu/api.v7/conf/conf_test.go
generated
vendored
@@ -1,35 +0,0 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/qiniu/x/rpc.v7"
|
||||
)
|
||||
|
||||
func TestUA(t *testing.T) {
|
||||
err := SetAppName("")
|
||||
if err != nil {
|
||||
t.Fatal("expect no error")
|
||||
}
|
||||
err = SetAppName("错误的UA")
|
||||
if err == nil {
|
||||
t.Fatal("expect an invalid ua format")
|
||||
}
|
||||
err = SetAppName("Test0-_.")
|
||||
if err != nil {
|
||||
t.Fatal("expect no error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormat(t *testing.T) {
|
||||
str := "tesT0.-_"
|
||||
SetAppName(str)
|
||||
v := rpc.UserAgent
|
||||
if !strings.Contains(v, str) {
|
||||
t.Fatal("should include user")
|
||||
}
|
||||
if !strings.HasPrefix(v, "QiniuGo/"+version) {
|
||||
t.Fatal("invalid format")
|
||||
}
|
||||
}
|
||||
2
vendor/github.com/qiniu/api.v7/conf/doc.go
generated
vendored
2
vendor/github.com/qiniu/api.v7/conf/doc.go
generated
vendored
@@ -1,2 +0,0 @@
|
||||
// conf 包提供了设置APP名称的方法。该APP名称会被放入API请求的UserAgent中,方便后续查询日志分析问题。
|
||||
package conf
|
||||
Reference in New Issue
Block a user