aboutsummaryrefslogtreecommitdiff
path: root/io.go
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2015-03-25 20:43:18 +0100
committerGibheer <gibheer@gmail.com>2015-03-25 20:43:18 +0100
commitba5a59931e015fc9a27ab631950c32fa890eec9f (patch)
treeabfe8b2f20a02ae147b7f82be1fe6321e530d4e0 /io.go
parentbb41ff218a14b6597607408de6efed37cc8dae40 (diff)
reformat code with gofmt
Yes, I know that this breaks the history search, but it had to be done sooner or later. I also adjusted my editor to follow the guidelines more closely.
Diffstat (limited to 'io.go')
-rw-r--r--io.go42
1 files changed, 23 insertions, 19 deletions
diff --git a/io.go b/io.go
index 382044e..56cc689 100644
--- a/io.go
+++ b/io.go
@@ -3,39 +3,43 @@ package main
// handle all io and de/encoding of data
import (
- "encoding/pem"
- "errors"
- "io/ioutil"
+ "encoding/pem"
+ "errors"
+ "io/ioutil"
)
var (
- ErrBlockNotFound = errors.New("block not found")
+ ErrBlockNotFound = errors.New("block not found")
)
// load a pem section from a file
func readSectionFromFile(path, btype string) ([]byte, error) {
- raw, err := readFile(path)
- if err != nil { return raw, err }
+ raw, err := readFile(path)
+ if err != nil {
+ return raw, err
+ }
- return decodeSection(raw, btype)
+ return decodeSection(raw, btype)
}
// read a file completely and report possible errors
func readFile(path string) ([]byte, error) {
- raw, err := ioutil.ReadFile(path)
- if err != nil { return EmptyByteArray, err }
- return raw, nil
+ raw, err := ioutil.ReadFile(path)
+ if err != nil {
+ return EmptyByteArray, err
+ }
+ return raw, nil
}
// decode a pem encoded file and search for the specified section
func decodeSection(data []byte, btype string) ([]byte, error) {
- rest := data
- for len(rest) > 0 {
- var block *pem.Block
- block, rest = pem.Decode(rest)
- if block.Type == btype {
- return block.Bytes, nil
- }
- }
- return EmptyByteArray, ErrBlockNotFound
+ rest := data
+ for len(rest) > 0 {
+ var block *pem.Block
+ block, rest = pem.Decode(rest)
+ if block.Type == btype {
+ return block.Bytes, nil
+ }
+ }
+ return EmptyByteArray, ErrBlockNotFound
}