diff --git a/src/config/go.mod b/config/go.mod similarity index 100% rename from src/config/go.mod rename to config/go.mod diff --git a/src/config/go.sum b/config/go.sum similarity index 100% rename from src/config/go.sum rename to config/go.sum diff --git a/src/config/loader.go b/config/loader.go similarity index 100% rename from src/config/loader.go rename to config/loader.go diff --git a/src/config/varpattern.go b/config/varpattern.go similarity index 100% rename from src/config/varpattern.go rename to config/varpattern.go diff --git a/go.mod b/go.mod deleted file mode 100644 index 443c0a2..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module gitea.meta-tech.academy/go/core - -go 1.20 diff --git a/go.sum b/go.sum deleted file mode 100644 index e69de29..0000000 diff --git a/go.work b/go.work index add1084..95dca5c 100644 --- a/go.work +++ b/go.work @@ -1,9 +1,8 @@ go 1.20 use ( - . - ./src/config - ./src/style - ./src/sys - ./src/util + ./config + ./style + ./sys + ./util ) diff --git a/go.work.sum b/go.work.sum index 6252bc4..8a453e6 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,2 +1,3 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= diff --git a/src/style/go.mod b/style/go.mod similarity index 75% rename from src/style/go.mod rename to style/go.mod index 0548c10..4e4de0b 100644 --- a/src/style/go.mod +++ b/style/go.mod @@ -3,7 +3,7 @@ module gitea.meta-tech.academy/go/core/style go 1.20 require ( - gitea.meta-tech.academy/go/core/util v0.0.0-20231102220428-c719e245b956 + gitea.meta-tech.academy/go/core/util v0.0.0-20231103003446-3792c0f48134 github.com/gookit/color v1.5.4 ) diff --git a/src/style/go.sum b/style/go.sum similarity index 77% rename from src/style/go.sum rename to style/go.sum index 5cb28be..048065f 100644 --- a/src/style/go.sum +++ b/style/go.sum @@ -1,5 +1,5 @@ -gitea.meta-tech.academy/go/core/util v0.0.0-20231102220428-c719e245b956 h1:XxyPD/jBTPqrf2o1N3QRmw8fPgvP7G9Z9Ba3DgH/Uz0= -gitea.meta-tech.academy/go/core/util v0.0.0-20231102220428-c719e245b956/go.mod h1:q+p8vM+aQ36GVspuTTupRBNDUKrsXCccx4k3f7IKfx8= +gitea.meta-tech.academy/go/core/util v0.0.0-20231103003446-3792c0f48134 h1:DTCBfyJ1HRBThmlYwFU6bLA2JV70inG1Yp/gug/pirk= +gitea.meta-tech.academy/go/core/util v0.0.0-20231103003446-3792c0f48134/go.mod h1:q+p8vM+aQ36GVspuTTupRBNDUKrsXCccx4k3f7IKfx8= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= diff --git a/src/style/style.go b/style/style.go similarity index 96% rename from src/style/style.go rename to style/style.go index f29779f..03ac6b0 100644 --- a/src/style/style.go +++ b/style/style.go @@ -62,7 +62,7 @@ func NewStyleByDef(def string) *Style { if len(d) > KEY_STYLE_OPTION { o = strings.Split(d[KEY_STYLE_OPTION], ",") } - util.prependToSliceStr(&c, "#") + util.PrependToSliceStr(&c, "#") var s *color.RGBStyle switch len(c) { case 1: @@ -72,7 +72,7 @@ func NewStyleByDef(def string) *Style { } for _, elm := range o { - s.AddOpts(color.Color(util.str2int(elm, 10, 0))) + s.AddOpts(color.Color(util.Str2int(elm, 10, 0))) } // s.Printf(" %-20s\n", d[KEY_STYLE_NAME]) return &Style{s, d[KEY_STYLE_NAME]} diff --git a/src/sys/go.mod b/sys/go.mod similarity index 100% rename from src/sys/go.mod rename to sys/go.mod diff --git a/src/sys/go.sum b/sys/go.sum similarity index 100% rename from src/sys/go.sum rename to sys/go.sum diff --git a/src/sys/sys.go b/sys/sys.go similarity index 100% rename from src/sys/sys.go rename to sys/sys.go diff --git a/src/util/go.mod b/util/go.mod similarity index 100% rename from src/util/go.mod rename to util/go.mod diff --git a/src/util/util.go b/util/util.go similarity index 52% rename from src/util/util.go rename to util/util.go index bad6353..0352940 100644 --- a/src/util/util.go +++ b/util/util.go @@ -5,19 +5,19 @@ import ( "strings" ) -func prependToSliceStr(strs *[]string, prefix string) { +func PrependToSliceStr(strs *[]string, prefix string) { for i, elm := range *strs { (*strs)[i] = prefix + elm } } -func appendToSliceStr(strs *[]string, suffix string) { +func AppendToSliceStr(strs *[]string, suffix string) { for i, elm := range *strs { (*strs)[i] = elm + suffix } } -func str2int64(str string, base int, fallback int64) int64 { +func Str2int64(str string, base int, fallback int64) int64 { str = strings.TrimSuffix(str, "\n") num, err := strconv.ParseInt(str, base, 64) if err != nil { @@ -26,14 +26,14 @@ func str2int64(str string, base int, fallback int64) int64 { return num } -func str2int(str string, base int, fallback int) int { - return int(str2int64(str, base, int64(fallback))) +func Str2int(str string, base int, fallback int) int { + return int(Str2int64(str, base, int64(fallback))) } -func castStrings2ints(strs *[]string) []int { +func CastStrings2ints(strs *[]string) []int { a := make([]int, len(*strs)) for i, elm := range *strs { - var f int = str2int(elm, 10, 0) + var f int = Str2int(elm, 10, 0) a[i] = f } return a