1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-13 09:12:28 +08:00

feat: add func GetRequestPublicIp and IsInternalIP (#40)

* add: add func GetRequestPublicIp and IsInternalIP

* fix: fix test fileutil fail

Co-authored-by: zhanghu <305835360@qq.com>
This commit is contained in:
tangqiu0205
2022-07-13 09:52:35 +08:00
committed by GitHub
parent 56b6844a2d
commit 957878dd98
3 changed files with 82 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ func TestCreateFile(t *testing.T) {
f := "./text.txt"
if CreateFile(f) {
file, err := os.Open(f)
defer file.Close()
assert.IsNil(err)
assert.Equal(f, file.Name())
} else {
@@ -111,6 +112,7 @@ func TestReadFileToString(t *testing.T) {
CreateFile(path)
f, _ := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0777)
defer f.Close()
f.WriteString("hello world")
content, _ := ReadFileToString(path)
@@ -218,6 +220,7 @@ func TestMiMeType(t *testing.T) {
assert := internal.NewAssert(t, "TestMiMeType")
f, _ := os.Open("./file.go")
defer f.Close()
assert.Equal("text/plain; charset=utf-8", MiMeType(f))
assert.Equal("text/plain; charset=utf-8", MiMeType("./file.go"))
}