Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kratos cli gives wrong import path when creating app with --nomod parameter #2937

Closed
qzwxsaedc opened this issue Jul 30, 2023 · 0 comments · Fixed by #2938
Closed

kratos cli gives wrong import path when creating app with --nomod parameter #2937

qzwxsaedc opened this issue Jul 30, 2023 · 0 comments · Fixed by #2938
Labels
bug Something isn't working

Comments

@qzwxsaedc
Copy link
Contributor

What happened:

  1. create a go.mod with go mod init proj
  2. create an app named "demo" with command kratos new demo --nomod
  3. open a file whose import path needs to be replaced with a local file, such as internal/server/http.go
  4. you can see that the import path does not conform to import path rules of golang. like this:

b4d9e836c24bfc508b94fe5e6a0d91bd

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):

  1. create a go.mod by go mod init proj
  2. create an app named "demo" with command kratos new demo --nomod
  3. 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?:

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.
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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant