test intra dependencies

This commit is contained in:
Mahdi Abu Yasmine 2023-11-03 00:36:07 +01:00
parent b7cc2aa66b
commit 8115bf6e96
20 changed files with 70 additions and 29 deletions

12
config/go.mod Normal file
View File

@ -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

12
config/go.sum Normal file
View File

@ -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=

View File

@ -6,9 +6,24 @@ import (
"regexp" "regexp"
"strings" "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" "gopkg.in/yaml.v3"
) )
func tutu() {
sys.RunShellCmd("ls -la")
}
func tata() {
test.Test()
}
func titi() {
util.Str2int("456", 10, -1)
}
type Cfg interface { type Cfg interface {
GetVar() []VarConfig GetVar() []VarConfig
} }
@ -39,6 +54,7 @@ func LoadConfig(path string, out Cfg, varPattern *VarPattern) {
cl.parse() cl.parse()
cl.refstr = []*reflect.Value{} cl.refstr = []*reflect.Value{}
// cl.setConfigPtr(outi) // cl.setConfigPtr(outi)
tutu()
} }
func (cl *ConfigLoader) findVarName(match string) string { func (cl *ConfigLoader) findVarName(match string) string {

3
go.mod
View File

@ -1,3 +0,0 @@
module gitea.meta-tech.academy/go/core
go 1.20

0
go.sum
View File

10
go.work
View File

@ -1,9 +1,9 @@
go 1.20 go 1.20
use ( use (
. ./config
./src/config ./style
./src/style ./sys
./src/sys ./test
./src/util ./util
) )

View File

@ -1,2 +1,3 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=

View File

@ -1,5 +0,0 @@
module gitea.meta-tech.academy/go/core/config
go 1.20
require gopkg.in/yaml.v3 v3.0.1

View File

@ -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=

View File

@ -3,7 +3,7 @@ module gitea.meta-tech.academy/go/core/style
go 1.20 go 1.20
require ( 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 github.com/gookit/color v1.5.4
) )

View File

@ -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-20231103003446-3792c0f48134 h1:DTCBfyJ1HRBThmlYwFU6bLA2JV70inG1Yp/gug/pirk=
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/go.mod h1:q+p8vM+aQ36GVspuTTupRBNDUKrsXCccx4k3f7IKfx8=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 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 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=

View File

@ -62,7 +62,7 @@ func NewStyleByDef(def string) *Style {
if len(d) > KEY_STYLE_OPTION { if len(d) > KEY_STYLE_OPTION {
o = strings.Split(d[KEY_STYLE_OPTION], ",") o = strings.Split(d[KEY_STYLE_OPTION], ",")
} }
util.prependToSliceStr(&c, "#") util.PrependToSliceStr(&c, "#")
var s *color.RGBStyle var s *color.RGBStyle
switch len(c) { switch len(c) {
case 1: case 1:
@ -72,7 +72,7 @@ func NewStyleByDef(def string) *Style {
} }
for _, elm := range o { 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]) // s.Printf(" %-20s\n", d[KEY_STYLE_NAME])
return &Style{s, d[KEY_STYLE_NAME]} return &Style{s, d[KEY_STYLE_NAME]}

3
test/go.mod Normal file
View File

@ -0,0 +1,3 @@
module gitea.meta-tech.academy/go/core/test
go 1.20

9
test/test.go Normal file
View File

@ -0,0 +1,9 @@
package test
import (
"fmt"
)
func Test() {
fmt.Printf("test")
}

View File

@ -5,19 +5,19 @@ import (
"strings" "strings"
) )
func prependToSliceStr(strs *[]string, prefix string) { func PrependToSliceStr(strs *[]string, prefix string) {
for i, elm := range *strs { for i, elm := range *strs {
(*strs)[i] = prefix + elm (*strs)[i] = prefix + elm
} }
} }
func appendToSliceStr(strs *[]string, suffix string) { func AppendToSliceStr(strs *[]string, suffix string) {
for i, elm := range *strs { for i, elm := range *strs {
(*strs)[i] = elm + suffix (*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") str = strings.TrimSuffix(str, "\n")
num, err := strconv.ParseInt(str, base, 64) num, err := strconv.ParseInt(str, base, 64)
if err != nil { if err != nil {
@ -26,14 +26,14 @@ func str2int64(str string, base int, fallback int64) int64 {
return num return num
} }
func str2int(str string, base int, fallback int) int { func Str2int(str string, base int, fallback int) int {
return int(str2int64(str, base, int64(fallback))) return int(Str2int64(str, base, int64(fallback)))
} }
func castStrings2ints(strs *[]string) []int { func CastStrings2ints(strs *[]string) []int {
a := make([]int, len(*strs)) a := make([]int, len(*strs))
for i, elm := range *strs { for i, elm := range *strs {
var f int = str2int(elm, 10, 0) var f int = Str2int(elm, 10, 0)
a[i] = f a[i] = f
} }
return a return a