Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

go - Scan the entire folder during file saving

I installed the Go extension for VS Code. This extension installed the following packages:

gocode: /Users/oleg/go/bin/gocode installed
gopkgs: /Users/oleg/go/bin/gopkgs installed
go-outline: /Users/oleg/go/bin/go-outline installed
go-symbols: go-symbols not installed
guru: guru not installed
gorename: /Users/oleg/go/bin/gorename installed
gotests: gotests not installed
gomodifytags: gomodifytags not installed
impl: impl not installed
fillstruct: fillstruct not installed
goplay: goplay not installed
godoctor: godoctor not installed
dlv: /Users/oleg/go/bin/dlv installed
gocode-gomod: /Users/oleg/go/bin/gocode-gomod installed
godef: /Users/oleg/go/bin/godef installed
goreturns: /Users/oleg/go/bin/goreturns installed
golint: /Users/oleg/go/bin/golint installed

I have a directory where I just save my code sketches for testing and when I simply save changes to the file (command+s) see the following messages in the OUTPUT console of VS Code.

Starting linting the current package at /Users/oleg/Documents/programming/go/example
Starting "go vet" under the folder /Users/oleg/Documents/programming/go/example
Starting building the current package at /Users/oleg/Documents/programming/go/example
Not able to determine import path of current package by using cwd: /Users/oleg/Documents/programming/go/example and Go workspace: 
/Users/oleg/Documents/programming/go/example>Finished running tool: /Users/oleg/go/bin/golint
/Users/oleg/Documents/programming/go/example/function_time.go:8:1 exported function Time should have comment or be unexported

/Users/oleg/Documents/programming/go/example>Finished running tool: /Users/oleg/App/go/bin/go build -o /var/folders/7y/rhj_y5j12sjb900l6pk9wxpw0000gp/T/vscode-goHFXY40/go-code-check .
/Users/oleg/Documents/programming/go/example/test.go:7:6 main redeclared in this block
/Users/oleg/Documents/programming/go/example/arrays.go:7:6 main redeclared in this block
/Users/oleg/Documents/programming/go/example/test2.go:7:6 main redeclared in this block
/Users/oleg/Documents/programming/go/example/test3.go:7:6 main redeclared in this block

/Users/oleg/Documents/programming/go/example>Finished running tool: /Users/oleg/App/go/bin/go vet .
/Users/oleg/Documents/programming/go/example/3.go:7:6 main redeclared in this block

As far as I understand, every time I save file go vet is automatically started, and checks all my files in the directory with the open file (not sure about that: then tries to build a package from all the files in the directory). I just want to check errors only in an open file, which I'm working on now, and not check the entire directory or something else.

Can anyone explain how to do this and in general what happens when I press command+s?

question from:https://stackoverflow.com/questions/65829968/scan-the-entire-folder-during-file-saving

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...