+
Skip to content

refactor: Remove redundant local vars in examples #3303

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions example/basicauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
username, _ := r.ReadString('\n')

fmt.Print("GitHub Password: ")
bytePassword, _ := term.ReadPassword(int(os.Stdin.Fd()))
password := string(bytePassword)
password, _ := term.ReadPassword(int(os.Stdin.Fd()))

Check warning on line 34 in example/basicauth/main.go

View check run for this annotation

Codecov / codecov/patch

example/basicauth/main.go#L34

Added line #L34 was not covered by tests

tp := github.BasicAuthTransport{
Username: strings.TrimSpace(username),
Password: strings.TrimSpace(password),
Password: strings.TrimSpace(string(password)),

Check warning on line 38 in example/basicauth/main.go

View check run for this annotation

Codecov / codecov/patch

example/basicauth/main.go#L38

Added line #L38 was not covered by tests
}

client := github.NewClient(tp.Client())
Expand Down
3 changes: 1 addition & 2 deletions example/codespaces/newreposecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@

var boxKey [32]byte
copy(boxKey[:], decodedPublicKey)
secretBytes := []byte(secretValue)
encryptedBytes, err := box.SealAnonymous([]byte{}, secretBytes, &boxKey, crypto_rand.Reader)
encryptedBytes, err := box.SealAnonymous([]byte{}, []byte(secretValue), &boxKey, crypto_rand.Reader)

Check warning on line 150 in example/codespaces/newreposecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newreposecretwithxcrypto/main.go#L150

Added line #L150 was not covered by tests
if err != nil {
return nil, fmt.Errorf("box.SealAnonymous failed with error %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions example/codespaces/newusersecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@

var boxKey [32]byte
copy(boxKey[:], decodedPublicKey)
secretBytes := []byte(secretValue)
encryptedBytes, err := box.SealAnonymous([]byte{}, secretBytes, &boxKey, crypto_rand.Reader)
encryptedBytes, err := box.SealAnonymous([]byte{}, []byte(secretValue), &boxKey, crypto_rand.Reader)

Check warning on line 157 in example/codespaces/newusersecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/codespaces/newusersecretwithxcrypto/main.go#L157

Added line #L157 was not covered by tests
if err != nil {
return nil, fmt.Errorf("box.SealAnonymous failed with error %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions example/newreposecretwithlibsodium/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ func encryptSecretWithPublicKey(publicKey *github.PublicKey, secretName string,
return nil, fmt.Errorf("base64.StdEncoding.DecodeString was unable to decode public key: %v", err)
}

secretBytes := []byte(secretValue)
encryptedBytes, exit := sodium.CryptoBoxSeal(secretBytes, decodedPublicKey)
encryptedBytes, exit := sodium.CryptoBoxSeal([]byte(secretValue), decodedPublicKey)
if exit != 0 {
return nil, errors.New("sodium.CryptoBoxSeal exited with non zero exit code")
}
Expand Down
3 changes: 1 addition & 2 deletions example/newreposecretwithxcrypto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@

var boxKey [32]byte
copy(boxKey[:], decodedPublicKey)
secretBytes := []byte(secretValue)
encryptedBytes, err := box.SealAnonymous([]byte{}, secretBytes, &boxKey, crypto_rand.Reader)
encryptedBytes, err := box.SealAnonymous([]byte{}, []byte(secretValue), &boxKey, crypto_rand.Reader)

Check warning on line 150 in example/newreposecretwithxcrypto/main.go

View check run for this annotation

Codecov / codecov/patch

example/newreposecretwithxcrypto/main.go#L150

Added line #L150 was not covered by tests
if err != nil {
return nil, fmt.Errorf("box.SealAnonymous failed with error %w", err)
}
Expand Down
5 changes: 2 additions & 3 deletions example/tagprotection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@
pattern = strings.TrimSpace(pattern)

fmt.Print("GitHub Token: ")
byteToken, _ := term.ReadPassword(int(os.Stdin.Fd()))
token, _ := term.ReadPassword(int(os.Stdin.Fd()))

Check warning on line 41 in example/tagprotection/main.go

View check run for this annotation

Codecov / codecov/patch

example/tagprotection/main.go#L41

Added line #L41 was not covered by tests
println()
token := string(byteToken)

ctx := context.Background()
client := github.NewClient(nil).WithAuthToken(token)
client := github.NewClient(nil).WithAuthToken(string(token))

Check warning on line 45 in example/tagprotection/main.go

View check run for this annotation

Codecov / codecov/patch

example/tagprotection/main.go#L45

Added line #L45 was not covered by tests

// create new tag protection
if pattern != "" {
Expand Down
5 changes: 2 additions & 3 deletions example/tokenauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@

func main() {
fmt.Print("GitHub Token: ")
byteToken, _ := term.ReadPassword(int(os.Stdin.Fd()))
token, _ := term.ReadPassword(int(os.Stdin.Fd()))

Check warning on line 24 in example/tokenauth/main.go

View check run for this annotation

Codecov / codecov/patch

example/tokenauth/main.go#L24

Added line #L24 was not covered by tests
println()
token := string(byteToken)

ctx := context.Background()
client := github.NewClient(nil).WithAuthToken(token)
client := github.NewClient(nil).WithAuthToken(string(token))

Check warning on line 28 in example/tokenauth/main.go

View check run for this annotation

Codecov / codecov/patch

example/tokenauth/main.go#L28

Added line #L28 was not covered by tests

user, resp, err := client.Users.Get(ctx, "")
if err != nil {
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载