- init
continuous-integration/drone/push Build is passing Details

master v1.0.0
李光春 2 years ago
commit c541489edc

@ -0,0 +1,17 @@
kind: pipeline
type: docker
name: clone
steps:
- name: Test
image: golang:1.18
commands:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go test -v ./...
- name: Benchmark
image: golang:1.18
commands:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go test -bench=. -benchmem

8
.gitignore vendored

@ -0,0 +1,8 @@
.env
.git
.svn
.idea
.vscode
*.log
gomod.sh
/vendor/

@ -0,0 +1,3 @@
module go.dtapp.net/goget
go 1.18

@ -0,0 +1,15 @@
package goget
func GetDefault(key, defVal any) any {
if key != nil {
return key
}
return defVal
}
func GetStringDefault(key, defVal string) string {
if key != "" {
return key
}
return defVal
}

@ -0,0 +1,23 @@
package goget
import "testing"
func TestGetDefault(t *testing.T) {
t.Log(GetDefault("test1", 1))
}
func TestGetStringDefault(t *testing.T) {
t.Log(GetStringDefault("test2", "1"))
}
func BenchmarkGetDefault(b *testing.B) {
for i := 0; i < b.N; i++ {
b.Log(GetDefault("test1", 1))
}
}
func BenchmarkGetStringDefault(b *testing.B) {
for i := 0; i < b.N; i++ {
b.Log(GetStringDefault("test2", "1"))
}
}

@ -0,0 +1,3 @@
package goget
const Version = "1.0.0"

@ -0,0 +1,7 @@
package goget
import "testing"
func TestVersion(t *testing.T) {
t.Log(Version)
}
Loading…
Cancel
Save