Created
August 13, 2019 18:02
-
-
Save jscharber/f21c78a31b00af8e372447f386dea485 to your computer and use it in GitHub Desktop.
go-code-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List available templates | |
func tplGet(tplListOption string) tplListResponse { | |
tplTLD := []string{"crd", "microservices", "serverless"} | |
tplSLD := []string{"ga", "experimental", "incubation"} | |
var response tplListResponse | |
for _, tld := range tplTLD { | |
for _, sld := range tplSLD { | |
dn := defaultTemplateDir + "/" + tld + "/" + sld | |
if _, err := os.Stat(dn); os.IsNotExist(err) { | |
continue | |
} | |
f, err := os.Open(dn) | |
if err != nil { | |
continue | |
} | |
list, err := f.Readdir(-1) | |
f.Close() | |
if err != nil { | |
continue | |
} | |
for _, fn := range list { | |
nrec := tplListItem{tld, sld, fn.Name()} | |
response.Templates = append(response.Templates, nrec) | |
} | |
} | |
} | |
return response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment