简体   繁体   中英

Get autocompletion with go.sum generated by go mod download

In VSCode, when I generate my go.sum using go mod download , I loose the autocompletion in VS Code.

I get it back if I generate it using go mod vendor , which generates different hashes in the go.sum (see a previous question about that here ).

However, I really would like always to have the go.sum version generated by go mod download instead of the other version, because otherwise I'm having hash verification issues in my CI system because of a divergence between expected and generated go.sum.

When I generate my go.sum with go mod download , gopls shows the following error:

Error loading workspace: err: exit status 1: stderr: go: updates to go.sum needed, disabled by -mod=readonly : packages.Load error

I guess this is because it needs to rewrite the go.sum because it runs a go mod vendor in background.

Is there some configuration I can use to have autocompletion while not forcing go.sum modification by go mod vendor ?

Have you checked the "PROBLEMS" section? When the go.sum mismatch is detected, the issue should be presented in the corresponding go.mod file along with the desired fix. Open the go.mod file, and select one of the quickfixes or code lenses suggested (either go mod tidy or update go.sum entry).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM