*: 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:
parent
690c85d4e8
commit
a8e4475c5e
3 changed files with 269 additions and 300 deletions
29
hierarchy.go
29
hierarchy.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue