Skip to content

Commit c13f52c

Browse files
authored
refactor: Simplify array copying (#4143)
1 parent 5a332d6 commit c13f52c

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

example/codespaces/newreposecretwithxcrypto/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ func encryptSecretWithPublicKey(publicKey *github.PublicKey, secretName, secretV
146146
return nil, fmt.Errorf("unable to decode public key: %v", err)
147147
}
148148

149-
var boxKey [32]byte
150-
copy(boxKey[:], decodedPublicKey)
149+
boxKey := [32]byte(decodedPublicKey)
151150
encryptedBytes, err := box.SealAnonymous([]byte{}, []byte(secretValue), &boxKey, crypto_rand.Reader)
152151
if err != nil {
153152
return nil, fmt.Errorf("box.SealAnonymous failed with error %w", err)

example/codespaces/newusersecretwithxcrypto/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ func encryptSecretWithPublicKey(publicKey *github.PublicKey, secretName, secretV
153153
return nil, fmt.Errorf("base64.StdEncoding.DecodeString was unable to decode public key: %v", err)
154154
}
155155

156-
var boxKey [32]byte
157-
copy(boxKey[:], decodedPublicKey)
156+
boxKey := [32]byte(decodedPublicKey)
158157
encryptedBytes, err := box.SealAnonymous([]byte{}, []byte(secretValue), &boxKey, crypto_rand.Reader)
159158
if err != nil {
160159
return nil, fmt.Errorf("box.SealAnonymous failed with error %w", err)

example/newreposecretwithxcrypto/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ func encryptSecretWithPublicKey(publicKey *github.PublicKey, secretName, secretV
146146
return nil, fmt.Errorf("base64.StdEncoding.DecodeString was unable to decode public key: %v", err)
147147
}
148148

149-
var boxKey [32]byte
150-
copy(boxKey[:], decodedPublicKey)
149+
boxKey := [32]byte(decodedPublicKey)
151150
encryptedBytes, err := box.SealAnonymous([]byte{}, []byte(secretValue), &boxKey, crypto_rand.Reader)
152151
if err != nil {
153152
return nil, fmt.Errorf("box.SealAnonymous failed with error %w", err)

github/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ func (c *Client) copy() *Client {
506506
clone.client.Timeout = c.client.Timeout
507507
}
508508
c.rateMu.Lock()
509-
copy(clone.rateLimits[:], c.rateLimits[:])
509+
clone.rateLimits = c.rateLimits
510510
c.rateMu.Unlock()
511511
return &clone
512512
}

0 commit comments

Comments
 (0)