You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two files marked with the tags below, each of which contains a function and either the first or the second is supposed to be compiled:
//go:build !A && B
// +build !A,B
func InitM() (m.M) {
b := & r.SampleStruct{}
return b
}
//go:build A && !B
// +build A,!B
func InitM() (m.M) {
a := & r.SampleStruct{}
return a
}
What did you see happen?
The problem is that when I call the function InitM in a package, neither of the function nor its return value is recognized
for instance in the code below, the function is called and its return value is stored in the variable a
a := InitM()
Assume that there exists a function called Run() in the class to which a belongs. If the function is called on a as below, the use of Run() is not recognized in the program since a is not recognized as well
a.Run()
What did you expect to see?
I know what distinguishes this feature is that it works and is recognized during the compilation of the program but the fact that no use of the functions applied is recognized is sort of annoying. During a code review, I was accused to define a function that was never used in the program because the guy reviewing, right clicked on the function Run() and after hitting "Go to references" did not find any
The text was updated successfully, but these errors were encountered:
I can only guess here, as you don't give necessary information about whether you have defined any build tags at all and how exactly the go toolchain is used in some review process. Maybe this post #29202 (comment) about gopls and build tags might help? This looks like a question for a forum like golang-nuts.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
Go version
go version 1.21
Output of
go env
in your module/workspace:What did you do?
I have two files marked with the tags below, each of which contains a function and either the first or the second is supposed to be compiled:
//go:build !A && B
// +build !A,B
func InitM() (m.M) {
b := & r.SampleStruct{}
return b
}
//go:build A && !B
// +build A,!B
func InitM() (m.M) {
a := & r.SampleStruct{}
return a
}
What did you see happen?
The problem is that when I call the function InitM in a package, neither of the function nor its return value is recognized
for instance in the code below, the function is called and its return value is stored in the variable a
a := InitM()
Assume that there exists a function called Run() in the class to which a belongs. If the function is called on a as below, the use of Run() is not recognized in the program since a is not recognized as well
a.Run()
What did you expect to see?
I know what distinguishes this feature is that it works and is recognized during the compilation of the program but the fact that no use of the functions applied is recognized is sort of annoying. During a code review, I was accused to define a function that was never used in the program because the guy reviewing, right clicked on the function Run() and after hitting "Go to references" did not find any
The text was updated successfully, but these errors were encountered: