Use gofmt.

On Jul 30, 2017 13:21, <[email protected]> wrote:

> What is the standard way to construct|format the following code snippet?
> I think the first is more readable; however, is there any accepted syntax I
> should be using working my way up the ladder as a senior developer?
>
> block, err := aes.NewCipher(key)
> if err != nil {
>  return err, nil, nil
> }
>
> nonce = make([]byte, 12)
> if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
>  return err, nil, nil
> }
>
> aesgcm, err := cipher.NewGCM(block)
> if err != nil {
>  return err, nil, nil
> }
>
> return nil, nonce, aesgcm.Seal(nil, nonce, plainText, nil)
>
>
> or
>
> block, err := aes.NewCipher(key)
> if err != nil {
>  return err, nil, nil
> } else {
>  nonce = make([]byte, 12)
>  if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
>   return err, nil, nil
>  } else {
>   aesgcm, err := cipher.NewGCM(block)
>   if err != nil {
>    return err, nil, nil
>   } else {
>    return nil, nonce, aesgcm.Seal(nil, nonce, plainText, nil)
>   }
>  }
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to