*: clean up

* Get rid of the isErr func in main()
* put main() logic closer to the top

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-11-16 14:15:42 -05:00
parent 690c85d4e8
commit a8e4475c5e
Signed by: vbatts
GPG key ID: 10937E57733F1362
3 changed files with 269 additions and 300 deletions

View file

@ -29,23 +29,24 @@ func (dh DirectoryHierarchy) WriteTo(w io.Writer) (n int64, err error) {
// CollectUsedKeywords collects and returns all the keywords used in a
// a DirectoryHierarchy
func CollectUsedKeywords(dh *DirectoryHierarchy) []string {
if dh != nil {
usedkeywords := []string{}
for _, e := range dh.Entries {
switch e.Type {
case FullType, RelativeType, SpecialType:
if e.Type != SpecialType || e.Name == "/set" {
kvs := e.Keywords
for _, kv := range kvs {
kw := KeyVal(kv).Keyword()
if !inSlice(kw, usedkeywords) {
usedkeywords = append(usedkeywords, kw)
}
if dh == nil {
return nil
}
usedkeywords := []string{}
for _, e := range dh.Entries {
switch e.Type {
case FullType, RelativeType, SpecialType:
if e.Type != SpecialType || e.Name == "/set" {
kvs := e.Keywords
for _, kv := range kvs {
kw := KeyVal(kv).Keyword()
if !inSlice(kw, usedkeywords) {
usedkeywords = append(usedkeywords, kw)
}
}
}
}
return usedkeywords
}
return nil
return usedkeywords
}