diff --git a/cmd/mt/config.go b/cmd/mt/config.go index 5f4cf07..667ba6e 100644 --- a/cmd/mt/config.go +++ b/cmd/mt/config.go @@ -12,24 +12,24 @@ import ( // FileConfig defines MT file config type FileConfig struct { MT struct { - DefaultSourceLocale *string `yaml:"default_source_locale,omitempty"` - DefaultTargetLocales []string `yaml:"default_target_locales,omitempty"` - InputDirectory *string `yaml:"input_directory,omitempty"` - OutputDirectory *string `yaml:"output_directory,omitempty"` - FileFormat *string `yaml:"file_format,omitempty"` - Directives map[string]string `yaml:"directives,omitempty"` - PollInterval *int `yaml:"poll_interval,omitempty"` - Timeout *int `yaml:"timeout,omitempty"` - } `yaml:"mt,omitempty"` + DefaultSourceLocale *string `yaml:"default_source_locale,omitzero"` + DefaultTargetLocales []string `yaml:"default_target_locales,omitzero"` + InputDirectory *string `yaml:"input_directory,omitzero"` + OutputDirectory *string `yaml:"output_directory,omitzero"` + FileFormat *string `yaml:"file_format,omitzero"` + Directives map[string]string `yaml:"directives,omitzero"` + PollInterval *int `yaml:"poll_interval,omitzero"` + Timeout *int `yaml:"timeout,omitzero"` + } `yaml:"mt,omitzero"` Files map[string]FileConfigMT `yaml:"files"` } // FileConfigMT defines file config type FileConfigMT struct { MT struct { - Type string `yaml:"type,omitempty"` - Directives map[string]string `yaml:"directives,omitempty,flow"` - } `yaml:"mt,omitempty"` + Type string `yaml:"type,omitzero"` + Directives map[string]string `yaml:"directives,omitzero,flow"` + } `yaml:"mt,omitzero"` } // BindFileConfig binds file config diff --git a/cmd/mt/detect/run_test.go b/cmd/mt/detect/run_test.go index 3d92010..2fcef7c 100644 --- a/cmd/mt/detect/run_test.go +++ b/cmd/mt/detect/run_test.go @@ -1,7 +1,6 @@ package detect import ( - "context" "errors" "testing" @@ -16,7 +15,7 @@ import ( ) func TestRunGetFilesError(t *testing.T) { - ctx := context.Background() + ctx := t.Context() initializer := cmdmocks.NewMockSrvInitializer(t) mtSrv := srvmocks.NewMockService(t) filesErr := errors.New("files error") @@ -39,7 +38,7 @@ func TestRunGetFilesError(t *testing.T) { } func TestRun(t *testing.T) { - ctx := context.Background() + ctx := t.Context() initializer := cmdmocks.NewMockSrvInitializer(t) mtSrv := srvmocks.NewMockService(t) diff --git a/cmd/mt/translate/run_test.go b/cmd/mt/translate/run_test.go index 56d3bde..81fb9ff 100644 --- a/cmd/mt/translate/run_test.go +++ b/cmd/mt/translate/run_test.go @@ -1,7 +1,6 @@ package translate import ( - "context" "errors" "github.com/stretchr/testify/mock" "testing" @@ -16,7 +15,7 @@ import ( ) func TestRunGetFilesError(t *testing.T) { - ctx := context.Background() + ctx := t.Context() initializer := cmdmocks.NewMockSrvInitializer(t) mtSrv := srvmocks.NewMockService(t) filesErr := errors.New("files error") @@ -39,7 +38,7 @@ func TestRunGetFilesError(t *testing.T) { } func TestRun(t *testing.T) { - ctx := context.Background() + ctx := t.Context() initializer := cmdmocks.NewMockSrvInitializer(t) mtSrv := srvmocks.NewMockService(t) @@ -62,7 +61,7 @@ func TestRun(t *testing.T) { } func TestRunRunTranslateErr(t *testing.T) { - ctx := context.Background() + ctx := t.Context() initializer := cmdmocks.NewMockSrvInitializer(t) mtSrv := srvmocks.NewMockService(t) diff --git a/go.mod b/go.mod index bc9819c..be479e8 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/Smartling/smartling-cli -go 1.24.3 +go 1.26.1 require ( dario.cat/mergo v1.0.2 - github.com/Smartling/api-sdk-go v0.0.0-20260129124741-cb37a6d9e493 + github.com/Smartling/api-sdk-go v0.0.0-20260330123236-a623cd723454 github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbletea v1.3.6 github.com/charmbracelet/lipgloss v1.1.0 @@ -16,36 +16,38 @@ require ( github.com/spf13/pflag v1.0.9 github.com/stretchr/testify v1.10.0 github.com/tcnksm/go-input v0.0.0-20180404061846-548a7d7a8ee8 - golang.org/x/sync v0.19.0 + golang.org/x/sync v0.20.0 ) require ( github.com/BurntSushi/toml v1.4.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/charmbracelet/colorprofile v0.3.1 // indirect - github.com/charmbracelet/x/ansi v0.9.3 // indirect - github.com/charmbracelet/x/cellbuf v0.0.13 // indirect - github.com/charmbracelet/x/term v0.2.1 // indirect + github.com/charmbracelet/colorprofile v0.4.3 // indirect + github.com/charmbracelet/x/ansi v0.11.6 // indirect + github.com/charmbracelet/x/cellbuf v0.0.15 // indirect + github.com/charmbracelet/x/term v0.2.2 // indirect + github.com/clipperhouse/displaywidth v0.11.0 // indirect + github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/mattn/go-runewidth v0.0.21 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.16.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/stretchr/objx v0.5.2 // indirect + github.com/stretchr/objx v0.5.3 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/zazab/zhash v0.0.0-20221031090444-2b0d50417446 // indirect - golang.org/x/crypto v0.47.0 // indirect - golang.org/x/sys v0.40.0 // indirect - golang.org/x/term v0.39.0 // indirect - golang.org/x/text v0.33.0 // indirect + golang.org/x/crypto v0.49.0 // indirect + golang.org/x/sys v0.42.0 // indirect + golang.org/x/term v0.41.0 // indirect + golang.org/x/text v0.35.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7480454..dfc77bc 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/Smartling/api-sdk-go v0.0.0-20260129124741-cb37a6d9e493 h1:08GU2Lepu81vnpDuayUttqkph/uGBJaaYuit32lPjAg= -github.com/Smartling/api-sdk-go v0.0.0-20260129124741-cb37a6d9e493/go.mod h1:BSUxirtjHu/mZmb41K2sKo8B8C2tfRP3NMCCV6yP27k= +github.com/Smartling/api-sdk-go v0.0.0-20260330123236-a623cd723454 h1:40Ar2lgQAjAH0ojVTF0ce3dOF3RuA+3HDkB5C6LVA40= +github.com/Smartling/api-sdk-go v0.0.0-20260330123236-a623cd723454/go.mod h1:c+o3w5XoR0b8tLXyZXnU/snLxmy5LluK+AYymuY66zk= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= @@ -12,18 +12,22 @@ github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU= github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc= -github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40= -github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0= +github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q= +github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= -github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0= -github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= -github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k= -github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= +github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= +github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= +github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= +github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= -github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= -github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= +github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= +github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= +github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= +github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= +github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= +github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= @@ -39,14 +43,14 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kovetskiy/lorg v1.2.0 h1:wNIUT/VOhcjKOmizDClZLvchbKFGW+dzf9fQXbSVS5E= github.com/kovetskiy/lorg v1.2.0/go.mod h1:rdiamaIRUCkX9HtFZd0D9dQqUbad21hipHk+sat7Z6s= -github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= -github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4= +github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= 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-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w= +github.com/mattn/go-runewidth v0.0.21/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= @@ -57,7 +61,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/reconquest/hierr-go v0.0.0-20170824213838-7d09c0176fd2 h1:v3ctQXyIHprCI7s42LGmMYbulnnpjeD4zcvq78D1ung= github.com/reconquest/hierr-go v0.0.0-20170824213838-7d09c0176fd2/go.mod h1:dF8sYs86hXr+kKjDVvxDZYMUsTm5yr0PFQqLer/xsrk= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -66,8 +69,8 @@ github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tcnksm/go-input v0.0.0-20180404061846-548a7d7a8ee8 h1:RB0v+/pc8oMzPsN97aZYEwNuJ6ouRJ2uhjxemJ9zvrY= @@ -76,20 +79,20 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavM github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/zazab/zhash v0.0.0-20221031090444-2b0d50417446 h1:75pcOSsb40+ub185cJI7g5uykl9Uu76rD5ONzK/4s40= github.com/zazab/zhash v0.0.0-20221031090444-2b0d50417446/go.mod h1:NtepZ8TEXErPsmQDMUoN72f8aIy4+xNinSJ3f1giess= -golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= -golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= -golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= -golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= -golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4= +golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= -golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY= -golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww= -golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= -golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU= +golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A= +golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= +golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= 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.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/services/files/run_pull.go b/services/files/run_pull.go index ab177d7..70ccb81 100644 --- a/services/files/run_pull.go +++ b/services/files/run_pull.go @@ -146,7 +146,7 @@ func (s service) downloadFileTranslations(params PullParams, file sdkfile.File) file, params.Format, useFormat, - map[string]interface{}{ + map[string]any{ "FileURI": file.FileURI, "Locale": locale.LocaleID, }, diff --git a/services/files/run_status.go b/services/files/run_status.go index a2c3f0a..08f0f6d 100644 --- a/services/files/run_status.go +++ b/services/files/run_status.go @@ -72,7 +72,7 @@ func (s service) RunStatus(params StatusParams) error { file, defaultFormat, format.UsePullFormat, - map[string]interface{}{ + map[string]any{ "FileURI": file.FileURI, "Locale": translation.LocaleID, }, diff --git a/services/helpers/cli_error/error.go b/services/helpers/cli_error/error.go index b6cac95..434a5b4 100644 --- a/services/helpers/cli_error/error.go +++ b/services/helpers/cli_error/error.go @@ -6,11 +6,11 @@ import "fmt" type Error struct { Cause error Description string - Args []interface{} + Args []any } // NewError creates a new Error instance with the provided cause, description, and optional arguments. -func NewError(cause error, description string, args ...interface{}) Error { +func NewError(cause error, description string, args ...any) Error { return Error{ Cause: cause, Description: description, diff --git a/services/helpers/config/config.go b/services/helpers/config/config.go index f3a4bb5..f91d7e0 100644 --- a/services/helpers/config/config.go +++ b/services/helpers/config/config.go @@ -14,12 +14,12 @@ import ( // FileConfig is the configuration from file. type FileConfig struct { Pull struct { - Format string `yaml:"format,omitempty"` - } `yaml:"pull,omitempty"` + Format string `yaml:"format,omitzero"` + } `yaml:"pull,omitzero"` Push struct { - Type string `yaml:"type,omitempty"` - Directives map[string]string `yaml:"directives,omitempty,flow"` - } `yaml:"push,omitempty"` + Type string `yaml:"type,omitzero"` + Directives map[string]string `yaml:"directives,omitzero,flow"` + } `yaml:"push,omitzero"` } // Config is the configuration for the Smartling CLI. @@ -27,12 +27,12 @@ type Config struct { UserID string `yaml:"user_id"` Secret string `yaml:"secret"` AccountID string `yaml:"account_id"` - ProjectID string `yaml:"project_id,omitempty"` + ProjectID string `yaml:"project_id,omitzero"` Threads uint32 `yaml:"threads"` Files map[string]FileConfig `yaml:"files"` - Proxy string `yaml:"proxy,omitempty"` + Proxy string `yaml:"proxy,omitzero"` Path string `yaml:"-"` } diff --git a/services/helpers/format/error.go b/services/helpers/format/error.go index 75c386f..1721af2 100644 --- a/services/helpers/format/error.go +++ b/services/helpers/format/error.go @@ -12,7 +12,7 @@ import ( type ExecutionError struct { Cause error Format string - Data interface{} + Data any } func (err ExecutionError) Error() string { diff --git a/services/helpers/format/execute_file_format.go b/services/helpers/format/execute_file_format.go index fe2fd39..c93f10d 100644 --- a/services/helpers/format/execute_file_format.go +++ b/services/helpers/format/execute_file_format.go @@ -13,7 +13,7 @@ func ExecuteFileFormat( file sdkfile.File, fallback string, getter func(config config.FileConfig) string, - data interface{}, + data any, ) (string, error) { local, err := config.GetFileConfig(file.FileURI) if err != nil { diff --git a/services/helpers/pointer/pointer.go b/services/helpers/pointer/pointer.go index 8bc4ada..8341cfe 100644 --- a/services/helpers/pointer/pointer.go +++ b/services/helpers/pointer/pointer.go @@ -1,10 +1,5 @@ package pointer -// NewP returns pointer for given value -func NewP[T any](v T) *T { - return &v -} - // PNew returns value for given pointer func PNew[T any](v *T) T { if v == nil { diff --git a/services/helpers/reader/read_files_from_stdin.go b/services/helpers/reader/read_files_from_stdin.go index 5c2073d..472d2b0 100644 --- a/services/helpers/reader/read_files_from_stdin.go +++ b/services/helpers/reader/read_files_from_stdin.go @@ -22,7 +22,7 @@ func ReadFilesFromStdin() ([]sdkfile.File, error) { var files []sdkfile.File - for _, line := range strings.Split(string(lines), "\n") { + for line := range strings.SplitSeq(string(lines), "\n") { if line == "" { continue } diff --git a/services/helpers/rlog/log_fn.go b/services/helpers/rlog/log_fn.go index ddffc33..bebc229 100644 --- a/services/helpers/rlog/log_fn.go +++ b/services/helpers/rlog/log_fn.go @@ -1,21 +1,21 @@ package rlog // Infof does logger.Infof -func Infof(format string, value ...interface{}) { +func Infof(format string, value ...any) { logger.Infof(format, value...) } // Error does logger.Error -func Error(value ...interface{}) { +func Error(value ...any) { logger.Error(value...) } // Errorf does logger.Errorf -func Errorf(format string, value ...interface{}) { +func Errorf(format string, value ...any) { logger.Errorf(format, value...) } // Debugf does logger.Debugf -func Debugf(format string, value ...interface{}) { +func Debugf(format string, value ...any) { logger.Debugf(format, value...) } diff --git a/services/init/run_init.go b/services/init/run_init.go index 99ead8c..8c37f6e 100644 --- a/services/init/run_init.go +++ b/services/init/run_init.go @@ -23,10 +23,10 @@ func (s service) RunInit(dryRun bool) error { prompt := func( message string, - value interface{}, + value any, zero bool, hidden bool, - variable interface{}, + variable any, ) { display := regexp.MustCompile(`^(.{1,3}).*$`).ReplaceAllString( fmt.Sprint(value), diff --git a/services/mt/run_detect.go b/services/mt/run_detect.go index 8569791..d2e18d0 100644 --- a/services/mt/run_detect.go +++ b/services/mt/run_detect.go @@ -9,7 +9,6 @@ import ( "time" clierror "github.com/Smartling/smartling-cli/services/helpers/cli_error" - "github.com/Smartling/smartling-cli/services/helpers/pointer" "github.com/Smartling/smartling-cli/services/helpers/rlog" api "github.com/Smartling/api-sdk-go/api/mt" @@ -51,7 +50,7 @@ func (s service) RunDetect(ctx context.Context, p DetectParams, files []string, } rlog.Debugf("finish upload") - update.Upload = pointer.NewP(true) + update.Upload = new(true) updates <- update rlog.Debugf("detect language") @@ -60,7 +59,7 @@ func (s service) RunDetect(ctx context.Context, p DetectParams, files []string, return nil, err } - update.Detect = pointer.NewP("start") + update.Detect = new("start") updates <- update started := time.Now() @@ -75,7 +74,7 @@ func (s service) RunDetect(ctx context.Context, p DetectParams, files []string, return nil, err } - update.Detect = pointer.NewP(detectionProgressResponse.State) + update.Detect = new(detectionProgressResponse.State) updates <- update rlog.Debugf("progress state: %s", detectionProgressResponse.State) @@ -93,7 +92,7 @@ func (s service) RunDetect(ctx context.Context, p DetectParams, files []string, } if len(detectionProgressResponse.DetectedSourceLanguages) > 0 { - update.Language = pointer.NewP(detectionProgressResponse.DetectedSourceLanguages[0].LanguageID) + update.Language = new(detectionProgressResponse.DetectedSourceLanguages[0].LanguageID) } updates <- update diff --git a/services/mt/run_translate.go b/services/mt/run_translate.go index 00f166c..2a465ea 100644 --- a/services/mt/run_translate.go +++ b/services/mt/run_translate.go @@ -12,7 +12,6 @@ import ( clierror "github.com/Smartling/smartling-cli/services/helpers/cli_error" globfiles "github.com/Smartling/smartling-cli/services/helpers/glob_files" - "github.com/Smartling/smartling-cli/services/helpers/pointer" "github.com/Smartling/smartling-cli/services/helpers/rlog" api "github.com/Smartling/api-sdk-go/api/mt" @@ -71,7 +70,7 @@ func (s service) RunTranslate(ctx context.Context, params TranslateParams, files } rlog.Debugf("finish upload") - update := TranslateUpdates{ID: uint32(fileID * len(params.TargetLocales)), Upload: pointer.NewP(true)} + update := TranslateUpdates{ID: uint32(fileID * len(params.TargetLocales)), Upload: new(true)} updates <- update if params.SourceLocale == "" { @@ -122,7 +121,7 @@ func (s service) RunTranslate(ctx context.Context, params TranslateParams, files return nil, err } - update.Translate = pointer.NewP("start") + update.Translate = new("start") updates <- update if err := translatorStartResponse.MtUID.Validate(); err != nil { @@ -151,7 +150,7 @@ func (s service) RunTranslate(ctx context.Context, params TranslateParams, files return nil, err } - update.Translate = pointer.NewP(progressResponse.State) + update.Translate = new(progressResponse.State) updates <- update rlog.Debugf("progress state: %s", progressResponse.State) @@ -179,7 +178,7 @@ func (s service) RunTranslate(ctx context.Context, params TranslateParams, files Directory: filepath.Dir(file), }) update.ID = uint32(fileID*len(params.TargetLocales) + updateID) - update.Locale = pointer.NewP(localeProcessStatus.LocaleID) + update.Locale = new(localeProcessStatus.LocaleID) updates <- update filenameLocale := strings.TrimSuffix(file, ext) + "_" + localeProcessStatus.LocaleID + ext @@ -222,8 +221,8 @@ func (s service) RunTranslate(ctx context.Context, params TranslateParams, files return nil, err } update.ID = uint32(fileID*len(params.TargetLocales) + updateID) - update.TranslatedFile = pointer.NewP(filepath.Base(filenameLocale)) - update.Download = pointer.NewP(true) + update.TranslatedFile = new(filepath.Base(filenameLocale)) + update.Download = new(true) updates <- update } } diff --git a/services/projects/run_info.go b/services/projects/run_info.go index ac7015d..4782ab8 100644 --- a/services/projects/run_info.go +++ b/services/projects/run_info.go @@ -35,7 +35,7 @@ func (s service) RunInfo() error { status = "archived" } - info := [][]interface{}{ + info := [][]any{ {"ID", details.ProjectID}, {"ACCOUNT", details.AccountUID}, {"NAME", details.ProjectName},