Skip to content

Commit 2ec691a

Browse files
authored
examples/basicauth: Simplify comma-ok type assertion in if statement. (google#558)
According to https://golang.org/ref/spec#Type_assertions: > For an expression x of interface type and a type T, the primary expression > > x.(T) > > asserts that x is not nil and that the value stored in x is of type T. [...] The > value of ok is true if the assertion holds. Therefore, this if statement can be simplified without changing behavior.
1 parent de9eb29 commit 2ec691a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/basicauth/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func main() {
3737
user, _, err := client.Users.Get("")
3838

3939
// Is this a two-factor auth error? If so, prompt for OTP and try again.
40-
if _, ok := err.(*github.TwoFactorAuthError); err != nil && ok {
40+
if _, ok := err.(*github.TwoFactorAuthError); ok {
4141
fmt.Print("\nGitHub OTP: ")
4242
otp, _ := r.ReadString('\n')
4343
tp.OTP = strings.TrimSpace(otp)

0 commit comments

Comments
 (0)