directories/printall.go

60 lines
1.4 KiB
Go

package main
import (
"fmt"
"reflect"
"runtime"
"strings"
"git.martyn.berlin/martyn/directories/base"
"git.martyn.berlin/martyn/directories/project"
"git.martyn.berlin/martyn/directories/user"
)
func GetFunctionName(i interface{}) string {
fullName := strings.Split(runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name(), "/")
funcName := fullName[len(fullName)-1]
return funcName
}
func printOne(f func() (string, error)) {
result, e := f()
if e != nil {
fmt.Printf("%s() : ERROR : %s\n", GetFunctionName(f), e.Error())
return
}
fmt.Printf("%s() : %s\n", GetFunctionName(f), result)
}
func printall() {
printOne(base.Home)
printOne(base.Cache)
printOne(base.Config)
printOne(base.Data)
printOne(base.DataLocal)
printOne(base.Executable)
printOne(base.Preferences)
printOne(base.Runtime)
printOne(base.State)
printOne(user.Home)
printOne(user.Audio)
printOne(user.Desktop)
printOne(user.Documents)
printOne(user.Downloads)
printOne(user.Fonts)
printOne(user.Pictures)
printOne(user.Public)
printOne(user.Templates)
printOne(user.Videos)
project.SetProjectName("example", "org.example.example", "Example Corp.", "Example App")
printOne(project.Cache)
printOne(project.Config)
printOne(project.Data)
printOne(project.DataLocal)
printOne(project.Preferences)
}
func main() {
printall()
}