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

fix duplicate import of global var path in symlink file #351

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

IfanTsai
Copy link
Contributor

@IfanTsai IfanTsai commented Sep 27, 2023

eg. main.go -> cmd/myproject/run.go

When run goc build ., redeclared error will be reported.
In main.go, the global var path is duplicated imported as follows:
package main; import . "myproject/src/gocbuild235e80d276dc"; import . "myproject/src/gocbuild234e80d276dc"

These two files treaded as two unrelated files in result of go list command, so goc imports the global var package twice.

eg. main.go -> cmd/myproject/run.go
When run `goc build .`, redeclared error will be reported.
In main.go, the global var path is duplicated imported as follows:
`package main; import . "myproject/src/gocbuild235e80d276dc"; import . "myproject/src/gocbuild234e80d276dc"`
@qiniu-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: IfanTsai
To complete the pull request process, please assign carlji
You can assign the PR to them by writing /assign @carlji in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@IfanTsai
Copy link
Contributor Author

/assign @CarlJi

@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #351 (6db3b82) into master (5b2b15a) will increase coverage by 0.09%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

❗ Current head 6db3b82 differs from pull request most recent head bccdb98. Consider uploading reports for the commit bccdb98 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #351      +/-   ##
==========================================
+ Coverage   70.61%   70.71%   +0.09%     
==========================================
  Files          34       34              
  Lines        2042     2042              
==========================================
+ Hits         1442     1444       +2     
+ Misses        488      486       -2     
  Partials      112      112              
Flag Coverage Δ
e2e-1.16.x ?
e2e-1.17.x ?
e2e-1.18.x ?
e2e-1.19.x ?
unittest-1.16.x 70.61% <ø> (ø)
unittest-1.17.x 70.51% <ø> (ø)
unittest-1.18.x 70.51% <ø> (-0.10%) ⬇️
unittest-1.19.x 70.61% <ø> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

@CarlJi
Copy link
Collaborator

CarlJi commented Oct 6, 2023

Hi @IfanTsai, I'm a bit confused about what you're referring to. Could you please provide a more complete example to clarify your request?

@IfanTsai
Copy link
Contributor Author

IfanTsai commented Oct 9, 2023

Hi @CarlJi, here is our project structure demo:

├── main.go -> cmd/my_project/run.go
├── internal
├── pkg
└── web
    ├── handlers
    │   ├── user.go
    │   ├── goods.go
    └── router.go

main.go in the root directory is actually a soft link to cmd/my_project/run.go. The default directory structure generated by our scaffolding like this. The go list command line treats main.go and cmd/my_project_run.go as they are two unrelated files, causing the goc to import global var path repeatedly in main.go, such as follows in /tmp/goc-build-87f625d33029/main.go:

image

package main; import . "my_project/src/gocbuild87f625d33029"; import . "my_project/src/gocbuild87f625d33029"
image

This PR can ensure only once import, such as follows in /tmp/goc-build-87f625d33029/main.go:

package main; import . "my_project/src/gocbuild87f625d33029";

@CarlJi
Copy link
Collaborator

CarlJi commented Oct 22, 2023

@IfanTsai Apologies for the delayed reply, the code LGTM, i will proceed with merging it

@CarlJi
Copy link
Collaborator

CarlJi commented Oct 22, 2023

/lgtm
/approve

@qiniu-prow qiniu-prow bot added the lgtm label Oct 22, 2023
@qiniu-prow
Copy link

qiniu-prow bot commented Oct 22, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CarlJi, IfanTsai

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@qiniu-prow qiniu-prow bot added the approved label Oct 22, 2023
@CarlJi CarlJi merged commit 5c8c1f4 into qiniu:master Oct 22, 2023
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants