From 8115bf6e96ee887609c3934c30932c1b46bb0e54 Mon Sep 17 00:00:00 2001 From: mahdi Date: Fri, 3 Nov 2023 00:36:07 +0100 Subject: [PATCH] test intra dependencies --- config/go.mod | 12 ++++++++++++ config/go.sum | 12 ++++++++++++ {src/config => config}/loader.go | 16 ++++++++++++++++ {src/config => config}/varpattern.go | 0 go.mod | 3 --- go.sum | 0 go.work | 10 +++++----- go.work.sum | 1 + src/config/go.mod | 5 ----- src/config/go.sum | 4 ---- {src/style => style}/go.mod | 2 +- {src/style => style}/go.sum | 4 ++-- {src/style => style}/style.go | 4 ++-- {src/sys => sys}/go.mod | 0 {src/sys => sys}/go.sum | 0 {src/sys => sys}/sys.go | 0 test/go.mod | 3 +++ test/test.go | 9 +++++++++ {src/util => util}/go.mod | 0 {src/util => util}/util.go | 14 +++++++------- 20 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 config/go.mod create mode 100644 config/go.sum rename {src/config => config}/loader.go (90%) rename {src/config => config}/varpattern.go (100%) delete mode 100644 go.mod delete mode 100644 go.sum delete mode 100644 src/config/go.mod delete mode 100644 src/config/go.sum rename {src/style => style}/go.mod (75%) rename {src/style => style}/go.sum (77%) rename {src/style => style}/style.go (96%) rename {src/sys => sys}/go.mod (100%) rename {src/sys => sys}/go.sum (100%) rename {src/sys => sys}/sys.go (100%) create mode 100644 test/go.mod create mode 100644 test/test.go rename {src/util => util}/go.mod (100%) rename {src/util => util}/util.go (52%) diff --git a/config/go.mod b/config/go.mod new file mode 100644 index 0000000..d0c3086 --- /dev/null +++ b/config/go.mod @@ -0,0 +1,12 @@ +module gitea.meta-tech.academy/go/core/config + +go 1.20 + +require ( + gitea.meta-tech.academy/go/core/sys v0.0.0-20231103003446-3792c0f48134 + gitea.meta-tech.academy/go/core/test v0.0.0-20231103010311-6108435b4311 + gitea.meta-tech.academy/go/core/util v0.0.0-20231103010311-6108435b4311 + gopkg.in/yaml.v3 v3.0.1 +) + +require golang.org/x/sys v0.13.0 // indirect diff --git a/config/go.sum b/config/go.sum new file mode 100644 index 0000000..a76c916 --- /dev/null +++ b/config/go.sum @@ -0,0 +1,12 @@ +gitea.meta-tech.academy/go/core/sys v0.0.0-20231103003446-3792c0f48134 h1:2r+IHzl0IS3yQIsBDU41+XeB+QOK95io55DdAGgij48= +gitea.meta-tech.academy/go/core/sys v0.0.0-20231103003446-3792c0f48134/go.mod h1:7GvZIAuk/3KbVMt8dTI+HFDtiEvk5OrtMrf6TUPAqwc= +gitea.meta-tech.academy/go/core/test v0.0.0-20231103010311-6108435b4311 h1:TPoKjY01UVOLjyRPZTUsXzwpjCMbadv/XgP9Wb7xrt4= +gitea.meta-tech.academy/go/core/test v0.0.0-20231103010311-6108435b4311/go.mod h1:IxtIf0ZnyckLaYvhE1tNEiSqoehb+iA6g1+BPcSYwz8= +gitea.meta-tech.academy/go/core/util v0.0.0-20231103010311-6108435b4311 h1:QsFN577qrxVIYJal35IpGZVKDxQO0VVm/jf3PvbCfN0= +gitea.meta-tech.academy/go/core/util v0.0.0-20231103010311-6108435b4311/go.mod h1:q+p8vM+aQ36GVspuTTupRBNDUKrsXCccx4k3f7IKfx8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/src/config/loader.go b/config/loader.go similarity index 90% rename from src/config/loader.go rename to config/loader.go index d8af616..6757579 100644 --- a/src/config/loader.go +++ b/config/loader.go @@ -6,9 +6,24 @@ import ( "regexp" "strings" + "gitea.meta-tech.academy/go/core/sys" + "gitea.meta-tech.academy/go/core/test" + "gitea.meta-tech.academy/go/core/util" "gopkg.in/yaml.v3" ) +func tutu() { + sys.RunShellCmd("ls -la") +} + +func tata() { + test.Test() +} + +func titi() { + util.Str2int("456", 10, -1) +} + type Cfg interface { GetVar() []VarConfig } @@ -39,6 +54,7 @@ func LoadConfig(path string, out Cfg, varPattern *VarPattern) { cl.parse() cl.refstr = []*reflect.Value{} // cl.setConfigPtr(outi) + tutu() } func (cl *ConfigLoader) findVarName(match string) string { 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..d385f4a 100644 --- a/go.work +++ b/go.work @@ -1,9 +1,9 @@ go 1.20 use ( - . - ./src/config - ./src/style - ./src/sys - ./src/util + ./config + ./style + ./sys + ./test + ./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/config/go.mod b/src/config/go.mod deleted file mode 100644 index d08f1ae..0000000 --- a/src/config/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module gitea.meta-tech.academy/go/core/config - -go 1.20 - -require gopkg.in/yaml.v3 v3.0.1 diff --git a/src/config/go.sum b/src/config/go.sum deleted file mode 100644 index a62c313..0000000 --- a/src/config/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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/test/go.mod b/test/go.mod new file mode 100644 index 0000000..f35362c --- /dev/null +++ b/test/go.mod @@ -0,0 +1,3 @@ +module gitea.meta-tech.academy/go/core/test + +go 1.20 diff --git a/test/test.go b/test/test.go new file mode 100644 index 0000000..4ecb1e2 --- /dev/null +++ b/test/test.go @@ -0,0 +1,9 @@ +package test + +import ( + "fmt" +) + +func Test() { + fmt.Printf("test") +} 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