include separator to the end
This commit is contained in:
parent
095e3e9d4c
commit
ed55c735e5
@ -23,11 +23,11 @@ func sourceDir(file string) string {
|
|||||||
dir := filepath.Dir(file)
|
dir := filepath.Dir(file)
|
||||||
dir = filepath.Dir(dir)
|
dir = filepath.Dir(dir)
|
||||||
|
|
||||||
parent := filepath.Dir(dir)
|
s := filepath.Dir(dir)
|
||||||
if filepath.Base(parent) == "gorm.io" {
|
if filepath.Base(s) != "gorm.io" {
|
||||||
return parent
|
s = dir
|
||||||
}
|
}
|
||||||
return dir
|
return s + string(filepath.Separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileWithLineNum return the file name and line number of the current file
|
// FileWithLineNum return the file name and line number of the current file
|
||||||
|
@ -8,20 +8,20 @@ func TestSourceDir(t *testing.T) {
|
|||||||
want string
|
want string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
file: "/Users/name/go/pkg/mod/gorm.io/gorm@v1.24.1/utils/utils.go",
|
file: "/Users/name/go/pkg/mod/gorm.io/gorm@v1.2.3/utils/utils.go",
|
||||||
want: "/Users/name/go/pkg/mod/gorm.io",
|
want: "/Users/name/go/pkg/mod/gorm.io/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "/go/work/proj/gorm/utils/utils.go",
|
file: "/go/work/proj/gorm/utils/utils.go",
|
||||||
want: "/go/work/proj/gorm",
|
want: "/go/work/proj/gorm/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "/go/work/proj/gorm_alias/utils/utils.go",
|
file: "/go/work/proj/gorm_alias/utils/utils.go",
|
||||||
want: "/go/work/proj/gorm_alias",
|
want: "/go/work/proj/gorm_alias/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "/go/work/proj/my.gorm.io/gorm@v1.24.1/utils/utils.go",
|
file: "/go/work/proj/my.gorm.io/gorm@v1.2.3/utils/utils.go",
|
||||||
want: "/go/work/proj/my.gorm.io/gorm@v1.24.1",
|
want: "/go/work/proj/my.gorm.io/gorm@v1.2.3/",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user