Skip to content

Commit a4056a0

Browse files
authored
Merge pull request #1989 from ianlv/master
refactor: replace []byte(fmt.Sprintf) with fmt.Appendf
2 parents 340886f + 7835e57 commit a4056a0

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

internal/command/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func UsageMetrics(command *cobra.Command, wg *sync.WaitGroup) {
375375

376376
// calculates a user ID that doesn't leak any personal information
377377
usr, _ := user.Current() // ignore err, just use empty string
378-
hash := sha256.Sum256([]byte(fmt.Sprintf("%s%s", usr.Username, usr.Uid)))
378+
hash := sha256.Sum256(fmt.Appendf(nil, "%s%s", usr.Username, usr.Uid))
379379
userID := base64.StdEncoding.EncodeToString(hash[:])
380380

381381
_ = client.Track(userID, "cli-command", &mixpanel.Event{

internal/emulator/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func trackRequestMiddleware(next http.Handler) http.Handler {
112112
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
113113
// Generate a unique user ID
114114
usr, _ := user.Current() // ignore err, just use empty string
115-
hash := sha256.Sum256([]byte(fmt.Sprintf("%s%s", usr.Username, usr.Uid)))
115+
hash := sha256.Sum256(fmt.Appendf(nil, "%s%s", usr.Username, usr.Uid))
116116
userID := base64.StdEncoding.EncodeToString(hash[:])
117117

118118
// Track the request in Mixpanel

internal/util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func AddToGitIgnore(filename string, loader flowkit.ReaderWriter) error {
6565
}
6666
return loader.WriteFile(
6767
gitIgnorePath,
68-
[]byte(fmt.Sprintf("%s\n%s", gitIgnoreFiles, filename)),
68+
fmt.Appendf(nil, "%s\n%s", gitIgnoreFiles, filename),
6969
filePermissions,
7070
)
7171
}

0 commit comments

Comments
 (0)