mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
Fix incorrect indentation (from spaces to tabs)
parent
e1d0bc433d
commit
efc97cb70c
@ -113,21 +113,21 @@ and if you need text, print to hexadecimal or base64:
|
|||||||
|
|
||||||
``` go
|
``` go
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
// "encoding/base64"
|
// "encoding/base64"
|
||||||
// "encoding/hex"
|
// "encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Key() string {
|
func Key() string {
|
||||||
buf := make([]byte, 16)
|
buf := make([]byte, 16)
|
||||||
_, err := rand.Read(buf)
|
_, err := rand.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err) // out of randomness, should never happen
|
panic(err) // out of randomness, should never happen
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%x", buf)
|
return fmt.Sprintf("%x", buf)
|
||||||
// or hex.EncodeToString(buf)
|
// or hex.EncodeToString(buf)
|
||||||
// or base64.StdEncoding.EncodeToString(buf)
|
// or base64.StdEncoding.EncodeToString(buf)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ import (
|
|||||||
"appengine/foo"
|
"appengine/foo"
|
||||||
"appengine/user"
|
"appengine/user"
|
||||||
|
|
||||||
"github.com/foo/bar"
|
"github.com/foo/bar"
|
||||||
"rsc.io/goversion/version"
|
"rsc.io/goversion/version"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@ -276,7 +276,7 @@ And encourages more robust and readable code:
|
|||||||
``` go
|
``` go
|
||||||
value, ok := Lookup(key)
|
value, ok := Lookup(key)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("no value for %q", key)
|
return fmt.Errorf("no value for %q", key)
|
||||||
}
|
}
|
||||||
return Parse(value)
|
return Parse(value)
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user