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 code that has been generated with fmt.Printf("%#v",somestruct) in files that are being properly
marked as such with // Code generated with somegen DO NOT EDIT. header in the first line.
Gopls errornously suggests to simplify Printf produced literals polluting the "Problems"
pane in the IDE (while properly refusing to format file on save).
Repr:
// Code generated with somegen DO NOT EDIT.package main
import"fmt"typeProofOBstruct{
A [][]string
}
funcmain(){
// x := ProofOB{A: [][]string{{"some value"}}}x:=ProofOB{A: [][]string{[]string{"some value"}}}
fmt.Printf("%#v\n",x)
}
// Result: main.ProofOB{A:[][]string{[]string{"some value"}}}
Note: simplifycompositelit is by default true, but I had to have set it to false as a workaround now.
Logs
No response
The text was updated successfully, but these errors were encountered:
ohir
added
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
labels
May 30, 2024
@idnandre Sure. We won't assign this to you, but if you chip in and send CLs, we will review them. (Take a look at https://go.dev/doc/contribute if you haven't before.)
You probably want to wait for gopls to require a Go Version >= 1.21 e.g. for #65917 to close. After 1.21 is available the function ast.IsGenerated will be available.
(You technically don't have to wait, but everything becomes about 4x harder. It requires create a library with built tags that makes sense both with and without go 1.21, and interprets "IsGenerated" in the correct direction whenever you use it when ast.IsGenerated is not available. Or duplicates the needed code. And write tests both before and after 1.21.)
gopls version
go env
What did you do?
I have code that has been generated with
fmt.Printf("%#v",somestruct)
in files that are being properlymarked as such with
// Code generated with somegen DO NOT EDIT.
header in the first line.Gopls errornously suggests to simplify Printf produced literals polluting the "Problems"
pane in the IDE (while properly refusing to format file on save).
Repr:
What did you see happen?
hundreds of:
What did you expect to see?
I expected Gopls to know from the "Code generated" header that code here CAN NOT be simplified.
Editor and settings
Note:
simplifycompositelit
is by default true, but I had to have set it to false as a workaround now.Logs
No response
The text was updated successfully, but these errors were encountered: