diff --git a/cmd/execution.go b/cmd/execution.go index ba1bf82..c47178c 100644 --- a/cmd/execution.go +++ b/cmd/execution.go @@ -3,14 +3,13 @@ package cmd import ( "fmt" - gu_console "github.com/thuongtruong109/gouse/console" - gu_shared "github.com/thuongtruong109/gouse/shared" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" ) func (d *Delivery) Execution() { loop := func() { - gu_console.Banner(gu_shared.DOUBLE_ALPHA, "SOUNDLIB") + gouse.Banner(gouse.DOUBLE_ALPHA, constants.APP_NAME) option := d.Run() d.HandleOption(option) @@ -22,10 +21,10 @@ func (d *Delivery) Execution() { var input string fmt.Scanln(&input) if input == "y" { - gu_console.Clear() + gouse.Cls() loop() } else { - gu_console.Clear() + gouse.Cls() d.helper.OutputNomal(constants.LABEL, constants.THANKYOU_TEXT) break } diff --git a/cmd/select.go b/cmd/select.go index 84a128e..3b7da84 100644 --- a/cmd/select.go +++ b/cmd/select.go @@ -3,9 +3,10 @@ package cmd import ( "fmt" "strings" + "github.com/AlecAivazis/survey/v2" + "github.com/thuongtruong109/gouse" "golang.org/x/exp/slices" - gu_shared "github.com/thuongtruong109/gouse/shared" ) type option struct { @@ -74,7 +75,7 @@ func (d *Delivery) Run() int8{ var scopes []string for _, option := range options { - scopes = append(scopes, fmt.Sprintf("%s%v", gu_shared.SCOPE_SYM, option.Name)) + scopes = append(scopes, fmt.Sprintf("%s%v", gouse.SCOPE_SYM, option.Name)) } var qs = []*survey.Question{ @@ -101,7 +102,7 @@ func (d *Delivery) Run() int8{ Key int8 Value string } - + var choices []Choice var choiceValue []string @@ -109,7 +110,7 @@ func (d *Delivery) Run() int8{ if strings.Contains(answers.Scopes, option.Name) { for _, item := range option.Items { for k, v := range item { - choiceValue = append(choiceValue, fmt.Sprintf(gu_shared.DOT_SYM + v)) + choiceValue = append(choiceValue, fmt.Sprintf(gouse.DOT_SYM + v)) getResult := &Choice{ Key: k, Value: v, @@ -142,7 +143,7 @@ func (d *Delivery) Run() int8{ } idx := slices.IndexFunc(choices, func(c Choice) bool { - return strings.Contains(answers2.Options, c.Value) + return strings.Contains(answers2.Options, c.Value) }) return int8(choices[idx].Key) diff --git a/go.mod b/go.mod index a8beb00..1da1fe8 100644 --- a/go.mod +++ b/go.mod @@ -5,19 +5,71 @@ go 1.23 require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/jedib0t/go-pretty/v6 v6.4.6 - github.com/thuongtruong109/gouse v0.1.0 + github.com/thuongtruong109/gouse v0.1.1-0.20241206030217-b9011911b337 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 ) require ( + github.com/bytedance/sonic v1.9.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/gin-gonic/gin v1.9.1 // indirect + github.com/go-echarts/go-echarts/v2 v2.3.3 // indirect + github.com/go-ini/ini v1.67.0 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.17.0 // indirect + github.com/go-redis/redis/v8 v8.11.5 // indirect + github.com/goccy/go-json v0.10.3 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/kelseyhightower/envconfig v1.4.0 // indirect + github.com/klauspost/compress v1.17.11 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mattn/go-colorable v0.1.2 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect - github.com/rivo/uniseg v0.4.4 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.15.0 // indirect - golang.org/x/text v0.16.0 // indirect + github.com/minio/md5-simd v1.1.2 // indirect + github.com/minio/minio-go/v7 v7.0.80 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/rs/xid v1.6.0 // indirect + github.com/shirou/gopsutil/v4 v4.24.6 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.mongodb.org/mongo-driver v1.17.1 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect + golang.org/x/text v0.20.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index cdabc3b..372697b 100644 --- a/go.sum +++ b/go.sum @@ -2,80 +2,220 @@ github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkk github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-echarts/go-echarts/v2 v2.3.3 h1:uImZAk6qLkC6F9ju6mZ5SPBqTyK8xjZKwSmwnCg4bxg= +github.com/go-echarts/go-echarts/v2 v2.3.3/go.mod h1:56YlvzhW/a+du15f3S2qUGNDfKnFOeJSThBIrVFHDtI= +github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= +github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74= +github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog= github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw= github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= +github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= +github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= +github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= +github.com/minio/minio-go/v7 v7.0.80 h1:2mdUHXEykRdY/BigLt3Iuu1otL0JTogT0Nmltg0wujk= +github.com/minio/minio-go/v7 v7.0.80/go.mod h1:84gmIilaX4zcvAWWzJ5Z1WI5axN+hAbM5w25xf8xvC0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= +github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64= +github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/thuongtruong109/gouse v0.1.0 h1:Wxk+zmXceL1f7NeqMdUmdl6hhVQtWzW/Dx8j+itHcoI= github.com/thuongtruong109/gouse v0.1.0/go.mod h1:HsqBRrlT3r5S+/XtXycoOki/mj4NwYWRhYnSngx2WdU= +github.com/thuongtruong109/gouse v0.1.1-0.20241206030217-b9011911b337 h1:ePgmI/1b6m+V7a6la6cHAikjFgyzP1YGhr+9lHeVXdU= +github.com/thuongtruong109/gouse v0.1.1-0.20241206030217-b9011911b337/go.mod h1:7ivh8z61oJrgBQtCwRqb1+pHNHahBXiXP7JuqkwHATE= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= +go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/internal/artists/repository.go b/internal/artists/repository.go index bff29a2..4aa2099 100644 --- a/internal/artists/repository.go +++ b/internal/artists/repository.go @@ -3,7 +3,7 @@ package artists import ( "fmt" - "github.com/thuongtruong109/gouse/io" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" ) @@ -14,7 +14,7 @@ func NewArtistRepository() *ArtistRepository { } func (ar *ArtistRepository) GetArtists() ([]*Artist, error) { - allArtist, err := io.ReadFileObj[*Artist](constants.ARTIST_PATH) + allArtist, err := gouse.ReadFileObj[*Artist](constants.ARTIST_PATH) if err != nil { return nil, err } @@ -59,7 +59,7 @@ func (ar *ArtistRepository) CreateArtist(newArtist *Artist) (*Artist, error) { artistInit = append(artistInit, newArtist) - err2 := io.WriteFileObj[[]*Artist](constants.ARTIST_PATH, artistInit) + err2 := gouse.WriteFileObj[[]*Artist](constants.ARTIST_PATH, artistInit) if err2 != nil { return nil, fmt.Errorf(constants.CREATE_FAILED) } @@ -84,7 +84,7 @@ func (ar *ArtistRepository) UpdateArtist(artistUpdate *Artist) (*Artist, error) artistInit = append(artistInit, allArtist[len(artistInit):]...) - err2 := io.WriteFileObj[[]*Artist](constants.ARTIST_PATH, artistInit) + err2 := gouse.WriteFileObj[[]*Artist](constants.ARTIST_PATH, artistInit) if err2 != nil { return nil, fmt.Errorf(constants.UPDATE_FAILED) } @@ -105,7 +105,7 @@ func (ar *ArtistRepository) DeleteArtist(artlistID string) error { } } - err2 := io.WriteFileObj[[]*Artist](constants.ARTIST_PATH, allArtist) + err2 := gouse.WriteFileObj[[]*Artist](constants.ARTIST_PATH, allArtist) if err2 != nil { return fmt.Errorf(constants.DELETE_FAILED) } diff --git a/internal/artists/usecase.go b/internal/artists/usecase.go index 73c90fa..76efc4a 100644 --- a/internal/artists/usecase.go +++ b/internal/artists/usecase.go @@ -3,8 +3,7 @@ package artists import ( "fmt" - gu_date "github.com/thuongtruong109/gouse/date" - gu_helper "github.com/thuongtruong109/gouse/helper" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" "github.com/thuongtruong109/soundlib/pkg/helpers" ) @@ -73,12 +72,12 @@ func (a *ArtistUsecase) CreateArtist() ([]string, string, error) { fmt.Scanln(&avatarUrl) artist := &Artist{ - ID: gu_helper.RandomID(), + ID: gouse.RandID(), Username: username, FullName: fullName, Bio: bio, AvatarUrl: avatarUrl, - DebutAt: gu_date.ISO(), + DebutAt: gouse.ISODate(), } result, time, err := helpers.QueryTimeTwoOutputWithParams[*Artist, *Artist](a.repo.CreateArtist)(artist) @@ -131,7 +130,7 @@ func (a *ArtistUsecase) UpdateArtist() ([]string, string, error) { FullName: fullName, Bio: bio, AvatarUrl: avatarUrl, - DebutAt: gu_date.ISO(), + DebutAt: gouse.ISODate(), } result, time, err := helpers.QueryTimeTwoOutputWithParams[*Artist, *Artist](a.repo.UpdateArtist)(newArtist) diff --git a/internal/genres/repository.go b/internal/genres/repository.go index cc0629a..0736459 100644 --- a/internal/genres/repository.go +++ b/internal/genres/repository.go @@ -3,7 +3,7 @@ package genres import ( "fmt" - "github.com/thuongtruong109/gouse/io" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" ) @@ -14,7 +14,7 @@ func NewGenreRepository() *GenreRepository { } func (gr *GenreRepository) GetGenres() ([]*Genre, error) { - genres, err := io.ReadFileObj[*Genre](constants.GENRE_PATH) + genres, err := gouse.ReadFileObj[*Genre](constants.GENRE_PATH) if err != nil { return nil, err @@ -60,7 +60,7 @@ func (gr *GenreRepository) CreateGenre(newGenre *Genre) (*Genre, error) { genresInit = append(genresInit, newGenre) - err2 := io.WriteFileObj(constants.GENRE_PATH, genresInit) + err2 := gouse.WriteFileObj(constants.GENRE_PATH, genresInit) if err2 != nil { return nil, fmt.Errorf(constants.CREATE_FAILED) } @@ -88,7 +88,7 @@ func (gr *GenreRepository) UpdateGenre(updateGenre *Genre) (*Genre, error) { genresInit = append(genresInit, allGenres[len(genresInit):]...) - err2 := io.WriteFileObj[[]*Genre](constants.GENRE_PATH, genresInit) + err2 := gouse.WriteFileObj[[]*Genre](constants.GENRE_PATH, genresInit) if err2 != nil { return nil, fmt.Errorf(constants.UPDATE_FAILED) } @@ -96,10 +96,7 @@ func (gr *GenreRepository) UpdateGenre(updateGenre *Genre) (*Genre, error) { } func (gr *GenreRepository) DeleteGenre(genreID string) error { - allGenres, err := gr.GetGenres() - if err != nil { - return err - } + allGenres, _ := gr.GetGenres() if allGenres == nil { return nil @@ -114,7 +111,7 @@ func (gr *GenreRepository) DeleteGenre(genreID string) error { } } - err2 := io.WriteFileObj[[]*Genre](constants.GENRE_PATH, genresInit) + err2 := gouse.WriteFileObj[[]*Genre](constants.GENRE_PATH, genresInit) if err2 != nil { return fmt.Errorf(constants.DELETE_FAILED) } diff --git a/internal/genres/usecase.go b/internal/genres/usecase.go index d0e74f4..06f9123 100644 --- a/internal/genres/usecase.go +++ b/internal/genres/usecase.go @@ -3,7 +3,7 @@ package genres import ( "fmt" - gu_helper "github.com/thuongtruong109/gouse/helper" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" "github.com/thuongtruong109/soundlib/pkg/helpers" ) @@ -68,7 +68,7 @@ func (g *GenreUsecase) CreateGenre() ([]string, string, error) { fmt.Scanln(&description) newGenre := &Genre{ - ID: gu_helper.RandomID(), + ID: gouse.RandID(), Name: name, Description: description, } diff --git a/internal/tracks/repository.go b/internal/tracks/repository.go index 851ceab..32834fd 100644 --- a/internal/tracks/repository.go +++ b/internal/tracks/repository.go @@ -1,7 +1,7 @@ package tracks import ( - "github.com/thuongtruong109/gouse/io" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" ) @@ -12,7 +12,7 @@ func NewTrackRepository() *TrackRepository { } func (tr *TrackRepository) GetTracks() ([]*Track, error) { - allTracks, err := io.ReadFileObj[*Track](constants.TRACK_PATH) + allTracks, err := gouse.ReadFileObj[*Track](constants.TRACK_PATH) if err != nil { return nil, err } @@ -57,7 +57,7 @@ func (tr *TrackRepository) CreateTrack(newTrack *Track) (*Track, error) { trackInit = append(trackInit, newTrack) - err := io.WriteFileObj(constants.TRACK_PATH, trackInit) + err := gouse.WriteFileObj(constants.TRACK_PATH, trackInit) if err != nil { return nil, err } @@ -89,12 +89,19 @@ func (tr *TrackRepository) DeleteTrack(trackId string) error { return nil } + var trackResult []*Track + for i, v := range allTracks { if v.ID == trackId { - allTracks = append(allTracks[:i], allTracks[i+1:]...) + trackResult = append(allTracks[:i], allTracks[i+1:]...) break } } + err := gouse.WriteFileObj(constants.TRACK_PATH, trackResult) + if err != nil { + return err + } + return nil } diff --git a/internal/tracks/usecase.go b/internal/tracks/usecase.go index 411e3dd..8dd8c61 100644 --- a/internal/tracks/usecase.go +++ b/internal/tracks/usecase.go @@ -3,8 +3,7 @@ package tracks import ( "fmt" - gu_date "github.com/thuongtruong109/gouse/date" - gu_helper "github.com/thuongtruong109/gouse/helper" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" "github.com/thuongtruong109/soundlib/pkg/helpers" ) @@ -81,14 +80,14 @@ func (a *TrackUsecase) CreateTrack() ([]string, string, error) { fmt.Scanln(&playCount) newTrack := &Track{ - ID: gu_helper.RandomID(), + ID: gouse.RandID(), Name: name, GenreID: genreID, ArtistID: artistID, FileUrl: fileURL, Duration: duration, PlayCount: playCount, - CreatedAt: gu_date.ISO(), + CreatedAt: gouse.ISODate(), } result, time, err := helpers.QueryTimeTwoOutputWithParams[*Track, *Track](a.repo.CreateTrack)(newTrack) @@ -152,7 +151,7 @@ func (a *TrackUsecase) UpdateTrack() ([]string, string, error) { FileUrl: fileURL, Duration: duration, PlayCount: playCount, - CreatedAt: gu_date.ISO(), + CreatedAt: gouse.ISODate(), } result, time, err := helpers.QueryTimeTwoOutputWithParams[*Track, *Track](a.repo.UpdateTrack)(newTrack) diff --git a/pkg/common/handler_wrapper.go b/pkg/common/handler_wrapper.go index da0356b..51aebca 100644 --- a/pkg/common/handler_wrapper.go +++ b/pkg/common/handler_wrapper.go @@ -3,7 +3,7 @@ package common import ( "fmt" - "github.com/thuongtruong109/gouse/types" + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/helpers" ) @@ -36,7 +36,7 @@ func (ch *CommonHandler) SuccessDataWrapper(desc string, body_output []string, t bodyLen := len(body_output) if bodyLen > 0 { if bodyLen > 1 { - helpers.TableOutput(ch.scope, body_output, "Total: "+types.IntToString(bodyLen), "\t- Status: "+desc, "- Time: "+time) + helpers.TableOutput(ch.scope, body_output, "Total: "+gouse.IntToString(bodyLen), "\t- Status: "+desc, "- Time: "+time) return } diff --git a/pkg/constants/console.go b/pkg/constants/console.go index b19ebcf..caa8ddd 100644 --- a/pkg/constants/console.go +++ b/pkg/constants/console.go @@ -15,4 +15,35 @@ const ( const ( Gray string = "\033[37m" +) + +const ( + GENRE_PATH string = "database/genres.json" + TRACK_PATH string = "database/tracks.json" + ARTIST_PATH string = "database/artists.json" + ALBUM_PATH string = "database/albums.json" + PLAYLIST_PATH string = "database/playlists.json" +) + +const ( + CREATE_FAILED string = "create failed" + GET_FAILED string = "get failed" + UPDATE_FAILED string = "update failed" + DELETE_FAILED string = "delete failed" + + CREATE_SUCCESS string = "create successfully" + GET_SUCCESS string = "get successfully" + UPDATE_SUCCESS string = "update successfully" + DELETE_SUCCESS string = "delete successfully" +) + +const ( + NOT_FOUND_DATA string = "not found data" + EMPTY_DATA string = "empty data" +) + +const ( + APP_NAME string = "SOUNDLIB" + THANKYOU_TEXT string = "\n --- ♥ Thank you for using service!" + AGAIN_TEXT string = "\n ¤ Do you want to continue? (y/n): " ) \ No newline at end of file diff --git a/pkg/constants/output.go b/pkg/constants/output.go deleted file mode 100644 index ecefa93..0000000 --- a/pkg/constants/output.go +++ /dev/null @@ -1,18 +0,0 @@ -package constants - -const ( - CREATE_FAILED string = "create failed" - GET_FAILED string = "get failed" - UPDATE_FAILED string = "update failed" - DELETE_FAILED string = "delete failed" - - CREATE_SUCCESS string = "create successfully" - GET_SUCCESS string = "get successfully" - UPDATE_SUCCESS string = "update successfully" - DELETE_SUCCESS string = "delete successfully" -) - -const ( - NOT_FOUND_DATA string = "not found data" - EMPTY_DATA string = "empty data" -) diff --git a/pkg/constants/path.go b/pkg/constants/path.go deleted file mode 100644 index f8f58cf..0000000 --- a/pkg/constants/path.go +++ /dev/null @@ -1,9 +0,0 @@ -package constants - -const ( - GENRE_PATH string = "database/genres.json" - TRACK_PATH string = "database/tracks.json" - ARTIST_PATH string = "database/artists.json" - ALBUM_PATH string = "database/albums.json" - PLAYLIST_PATH string = "database/playlists.json" -) \ No newline at end of file diff --git a/pkg/constants/symbol.go b/pkg/constants/symbol.go deleted file mode 100644 index 8616c1c..0000000 --- a/pkg/constants/symbol.go +++ /dev/null @@ -1,6 +0,0 @@ -package constants - -const ( - THANKYOU_TEXT = "\n --- ♥ Thank you for using service!" - AGAIN_TEXT = "\n ¤ Do you want to continue? (y/n): " -) \ No newline at end of file diff --git a/pkg/helpers/output.go b/pkg/helpers/output.go index ce99043..ea4e36d 100644 --- a/pkg/helpers/output.go +++ b/pkg/helpers/output.go @@ -1,8 +1,8 @@ package helpers import ( + "github.com/thuongtruong109/gouse" "github.com/thuongtruong109/soundlib/pkg/constants" - "github.com/thuongtruong109/gouse/shared" ) func (h *Helper) OutputColor(level int8) string { @@ -10,38 +10,38 @@ func (h *Helper) OutputColor(level int8) string { case constants.DEBUG: return constants.Gray case constants.INFO: - return shared.GREEN_FG + return gouse.GREEN_FG case constants.WARNING: - return shared.ORANGE_FG + return gouse.ORANGE_FG case constants.ERROR: - return shared.RED_FG + return gouse.RED_FG case constants.FATAL: - return shared.PURPLE_FG + return gouse.PURPLE_FG case constants.LABEL: - return shared.CYAN_FG + return gouse.CYAN_FG case constants.DESC: - return shared.YELLOW_FG + return gouse.YELLOW_FG case constants.INPUT: - return shared.CYAN_FG + return gouse.CYAN_FG case constants.QUERY: - return shared.PINK_FG + return gouse.PINK_FG default: - return shared.WHITE_FG + return gouse.WHITE_FG } } func (h *Helper) OutputSuccess(statusMsg string) { - println(shared.GREEN_FG + "\n::: Status: " + statusMsg + shared.DEFAULT_FG) + println(gouse.GREEN_FG + "\n::: Status: " + statusMsg + gouse.DEFAULT_FG) } func (h *Helper) OutputError(statusMsg string, err string) { - println(shared.RED_FG + "\n::: Status: " + statusMsg + "\n::: Message: " + err + shared.DEFAULT_FG) + println(gouse.RED_FG + "\n::: Status: " + statusMsg + "\n::: Message: " + err + gouse.DEFAULT_FG) } func (h *Helper) OutputNomal(label int8, msg string) { - println(h.OutputColor(label) + msg + shared.DEFAULT_FG) + println(h.OutputColor(label) + msg + gouse.DEFAULT_FG) } func OutputTime(time string) { - println(shared.PURPLE_FG + "\n::: Query time: " + time + shared.DEFAULT_FG) + println(gouse.PURPLE_FG + "\n::: Query time: " + time + gouse.DEFAULT_FG) } \ No newline at end of file diff --git a/pkg/helpers/table.go b/pkg/helpers/table.go index b789251..5a6d2cd 100644 --- a/pkg/helpers/table.go +++ b/pkg/helpers/table.go @@ -4,14 +4,14 @@ import ( "os" "github.com/jedib0t/go-pretty/v6/table" - "github.com/thuongtruong109/gouse/types" + "github.com/thuongtruong109/gouse" ) func TableOutput[H, R any, S, D, T string](header H, rows []R, sum S, description D, time T) { t := table.NewWriter() t.SetOutputMirror(os.Stdout) - if !types.IsNil(header) { + if !gouse.IsNil(header) { t.AppendHeader(table.Row{header}) } @@ -28,7 +28,7 @@ func TableOutput[H, R any, S, D, T string](header H, rows []R, sum S, descriptio } } - if !types.IsNil(sum) && !types.IsNil(description) && !types.IsNil(time) { + if !gouse.IsNil(sum) && !gouse.IsNil(description) && !gouse.IsNil(time) { t.AppendFooter(table.Row{sum, description, time}) } @@ -40,11 +40,11 @@ func TableNoOutput[H any, D, T string](header H, description D, time T) { t := table.NewWriter() t.SetOutputMirror(os.Stdout) - if !types.IsNil(header) { + if !gouse.IsNil(header) { t.AppendHeader(table.Row{header}) } - if !types.IsNil(description) && !types.IsNil(time) { + if !gouse.IsNil(description) && !gouse.IsNil(time) { t.AppendFooter(table.Row{description, time}) }