How to force VSCode to ignore linting the next line of golang code?

Viewed 79

I like my code to look clean. I try to follow recommendations, etc. It helps keep everything tidy, conforming, and decent.

But sometimes, you need to defeat the linter because it has a bug, or it just doesn't understand what you intend.

In this case, I have the following code:

fmt.Println("Enter values between %00 and %0f.")

VSCode complains with:

fmt.Println call has possible formatting directive %0f (printf)

That's a reasonable thing for it to think, and I thank it very much for warning me of a possible mistake I might have made... but in this specific case, I really do want it to print %0f as-is. I really, really know what I'm doing here.

Normally, I might do something like this:

//lint:ignore printf No, really, this is what I want
fmt.Println("Enter values between %00 and %0f.")

But VSCode still gives the yellow wavy line and completely ignores the lint:ignore directive.

I must work around this annoyance with:

fmt.Printf("Enter values between %%00 and %%0f.\n")

But I'd prefer to use the original syntax, as the intent is clearer, and the line matches what I've written everywhere else in this part of the overall code.

So, how do I put my foot down and freaking tell the cursed program to stop placing its errant yellow wavy line because, dammit, I really do know what the I'm doing? It is not only distracting, but it wastes my time as I keep looking over the 'linting error' only to see it's not an issue.

Edit

Some additional information might be useful.

In my desire to keep things as uncomplicated as reasonably possible, I use the 'Go' extension, with no changes to the linter it defaults to using.

Examining these settings, it looks like it's using staticcheck. And, indeed, I see that in the local bin folder.

But staticcheck doesn't care. It doesn't complain at all about the fmt.Println() I wrote, even if I don't have a //lint:ignore line above it, when I run it explicitly.

0 Answers
Related