-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
all: fix golangci-lint errors #14555
Conversation
1f9d588
to
f9bd471
Compare
ssh/tailssh/incubator.go
Outdated
fmt.Sprintf("PATH=" + defaultPathForUser(&u.User)), | ||
fmt.Sprintf("SHELL=%v", u.LoginShell()), | ||
fmt.Sprintf("USER=%v", u.Username), | ||
fmt.Sprintf("HOME=%v", u.HomeDir), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the printf on these, thinking that we may want to use %q
at some point, in case any of these values have spaces. I didn't do that proactively since I'm not 100% sure quoted strings are supported here, and didn't take the time to investigate further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think they're quoted at this level.
Sprintf is fine, or concat. Your call. I might do %s for extra clarity that we know they're strings. But %v is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done (switched to %s
)
ssh/tailssh/incubator.go
Outdated
fmt.Sprintf("PATH=" + defaultPathForUser(&u.User)), | ||
fmt.Sprintf("SHELL=%v", u.LoginShell()), | ||
fmt.Sprintf("USER=%v", u.Username), | ||
fmt.Sprintf("HOME=%v", u.HomeDir), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think they're quoted at this level.
Sprintf is fine, or concat. Your call. I might do %s for extra clarity that we know they're strings. But %v is also fine.
if got, want := cache.updated, time.Unix(0, 0); !got.Equal(want) { | ||
t.Fatalf("got %s, want %s", got, want) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this fails, the local PDT or whatever time from time.Unix(0, 0) will probably be misleading
I'd prefer to normalize the timezone in the got/want variables first and then == would be fine (if the lint tool knew that, but it won't) just for the failure output to be nice. But Equal is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converted both values to UTC
cmd/tailscale/cli/risks.go
Outdated
@@ -77,7 +77,7 @@ func presentRiskToUser(riskType, riskMessage, acceptedRisks string) error { | |||
for left := riskAbortTimeSeconds; left > 0; left-- { | |||
msg := fmt.Sprintf("\rContinuing in %d seconds...", left) | |||
msgLen = len(msg) | |||
printf(msg) | |||
print(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't equivalent. The printf before was our indirection to work in wasm/etc:
var Stderr io.Writer = os.Stderr
var Stdout io.Writer = os.Stdout
func errf(format string, a ...any) {
fmt.Fprintf(Stderr, format, a...)
}
func printf(format string, a ...any) {
fmt.Fprintf(Stdout, format, a...)
}
By using print
, you're using the implementation's print
(not even part of the language!)
So I'd do printf("%s", msg)
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh snap... totally didn't notice this was a local function and not a builtin. fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also didn't realized that print
and println
weren't part of the language. TIL https://go.dev/ref/spec#Bootstrapping
These erroneously blocked a recent PR, which I fixed by simply re-running CI. But we might as well fix them anyway. These are mostly `printf` to `print` and a couple of `!=` to `!Equal()` Updates #cleanup Signed-off-by: Will Norris <will@tailscale.com>
f9bd471
to
8b73757
Compare
These erroneously blocked a recent PR, which I fixed by simply re-running CI. But we might as well fix them anyway. These are mostly
printf
toprint
and a couple of!=
to!Equal()
Updates #cleanup