From 321572641750582d05588d17c42d2408a75a8958 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 21 Sep 2024 12:02:09 -0300 Subject: [PATCH] use stdout() function instead of fmt.Println() in some places. --- encrypt_decrypt.go | 12 ++++++------ key.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/encrypt_decrypt.go b/encrypt_decrypt.go index 8ef39e7..e517fdf 100644 --- a/encrypt_decrypt.go +++ b/encrypt_decrypt.go @@ -45,7 +45,7 @@ var encrypt = &cli.Command{ if err != nil { return err } - fmt.Println(ciphertext) + stdout(ciphertext) } else { ss, err := nip04.ComputeSharedSecret(target, sec) if err != nil { @@ -55,7 +55,7 @@ var encrypt = &cli.Command{ if err != nil { return fmt.Errorf("failed to encrypt as nip04: %w", err) } - fmt.Println(ciphertext) + stdout(ciphertext) } } else { kr, err := gatherKeyerFromArguments(ctx, c) @@ -67,7 +67,7 @@ var encrypt = &cli.Command{ if err != nil { return fmt.Errorf("failed to encrypt: %w", err) } - fmt.Println(res) + stdout(res) } return nil @@ -110,7 +110,7 @@ var decrypt = &cli.Command{ if err != nil { return err } - fmt.Println(plaintext) + stdout(plaintext) } else { ss, err := nip04.ComputeSharedSecret(source, sec) if err != nil { @@ -120,7 +120,7 @@ var decrypt = &cli.Command{ if err != nil { return fmt.Errorf("failed to encrypt as nip04: %w", err) } - fmt.Println(plaintext) + stdout(plaintext) } } else { kr, err := gatherKeyerFromArguments(ctx, c) @@ -132,7 +132,7 @@ var decrypt = &cli.Command{ if err != nil { return fmt.Errorf("failed to encrypt: %w", err) } - fmt.Println(res) + stdout(res) } return nil diff --git a/key.go b/key.go index 826cb7f..df5ef2a 100644 --- a/key.go +++ b/key.go @@ -252,13 +252,13 @@ However, if the intent is to check if two existing Nostr pubkeys match a given c } res, _ := json.MarshalIndent(result, "", " ") - fmt.Println(string(res)) + stdout(string(res)) return nil }, } -func getSecretKeysFromStdinLinesOrSlice(ctx context.Context, c *cli.Command, keys []string) chan string { +func getSecretKeysFromStdinLinesOrSlice(ctx context.Context, _ *cli.Command, keys []string) chan string { ch := make(chan string) go func() { for sec := range getStdinLinesOrArgumentsFromSlice(keys) {