-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
What happened:
- create a go.mod with
go mod init proj
- create an app named "demo" with command
kratos new demo --nomod
- open a file whose import path needs to be replaced with a local file, such as
internal/server/http.go
- you can see that the import path does not conform to import path rules of golang. like this:
What you expected to happen:
import path should be github.com/CyanPigeon/toktik/demo/api/demo/v1
and github.com/CyanPigeon/toktik/demo/internal/biz
in the example previous.
How to reproduce it (as minimally and precisely as possible):
- create a go.mod by
go mod init proj
- create an app named "demo" with command
kratos new demo --nomod
- open a file whose import path needs to be replaced with a local file, such as
internal/server/http.go
Anything else we need to know?:
kratos/cmd/kratos/internal/project/project.go
Lines 94 to 95 in 072b2ee
p.Path = filepath.Join(strings.TrimPrefix(workingDir, projectRoot+"/"), p.Name) | |
done <- p.Add(ctx, workingDir, repoURL, branch, mod) |
Project.Path
was set to an absolute path before Project.Add()
is called.kratos/cmd/kratos/internal/project/add.go
Line 43 in 072b2ee
if err := repo.CopyToV2(ctx, to, filepath.Join(mod, p.Path), repoAddIgnores, []string{filepath.Join(p.Path, "api"), "api"}); err != nil { |
Here the absolute path is incorrectly concatenated with the module name via filepath.Join()
, resulting in this error.
Environment:
- Kratos version (use
kratos -v
): kratos version v2.6.3 - Go version (use
go version
): go version go1.20.6 windows/amd64 - OS (e.g:
cat /etc/os-release
): Windows 11 22621.1992 - Others:
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working