From 730da782f90fbeb076b5a5fd68a3c8857802fdd1 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:58:10 +0000 Subject: [PATCH] style: format code with Go fmt This commit fixes the style issues introduced in 5d008d4 according to the output from Go fmt. Details: None --- apps/cliq-app/config/settings_service.go | 48 ++++++++--------- apps/cliq-hub-backend/cmd/server/main.go | 52 +++++++++--------- .../internal/config/config.go | 36 ++++++------- apps/cliq-hub-backend/internal/errors/api.go | 20 +++---- .../internal/template/model.go | 34 ++++++------ .../internal/version/version.go | 6 +-- packages/cliqfile/validator_test.go | 54 +++++++++---------- 7 files changed, 125 insertions(+), 125 deletions(-) diff --git a/apps/cliq-app/config/settings_service.go b/apps/cliq-app/config/settings_service.go index 652fef1..7043494 100644 --- a/apps/cliq-app/config/settings_service.go +++ b/apps/cliq-app/config/settings_service.go @@ -11,7 +11,7 @@ import ( ) type AppSettings struct { - CliqHubBaseURL string `mapstructure:"cliq_hub_base_url"` + CliqHubBaseURL string `mapstructure:"cliq_hub_base_url"` } type SettingsService struct { @@ -24,7 +24,7 @@ func NewSettingsService() (*SettingsService, error) { vp.SetEnvPrefix("CLIQ") vp.AutomaticEnv() - vp.SetDefault("cliq_hub_base_url", "http://localhost:8080") + vp.SetDefault("cliq_hub_base_url", "http://localhost:8080") cfgDir, err := os.UserConfigDir() if err != nil { @@ -52,22 +52,22 @@ func NewSettingsService() (*SettingsService, error) { } func (s *SettingsService) Load() (*AppSettings, error) { - var cfg AppSettings - if err := s.vp.Unmarshal(&cfg); err != nil { - return nil, fmt.Errorf("unmarshal settings: %w", err) - } - return &cfg, nil + var cfg AppSettings + if err := s.vp.Unmarshal(&cfg); err != nil { + return nil, fmt.Errorf("unmarshal settings: %w", err) + } + return &cfg, nil } func (s *SettingsService) Save(in *AppSettings) error { - if in == nil { - return errors.New("settings is nil") - } - if err := validateURL(in.CliqHubBaseURL); err != nil { - return err - } - s.vp.Set("cliq_hub_base_url", in.CliqHubBaseURL) - return s.vp.WriteConfigAs(s.configFile) + if in == nil { + return errors.New("settings is nil") + } + if err := validateURL(in.CliqHubBaseURL); err != nil { + return err + } + s.vp.Set("cliq_hub_base_url", in.CliqHubBaseURL) + return s.vp.WriteConfigAs(s.configFile) } func (s *SettingsService) Update(partial map[string]any) error { @@ -75,15 +75,15 @@ func (s *SettingsService) Update(partial map[string]any) error { return nil } // Validate known keys - if v, ok := partial["cliq_hub_base_url"]; ok { - if str, ok2 := v.(string); ok2 { - if err := validateURL(str); err != nil { - return err - } - s.vp.Set("cliq_hub_base_url", str) - } - } - return s.vp.WriteConfigAs(s.configFile) + if v, ok := partial["cliq_hub_base_url"]; ok { + if str, ok2 := v.(string); ok2 { + if err := validateURL(str); err != nil { + return err + } + s.vp.Set("cliq_hub_base_url", str) + } + } + return s.vp.WriteConfigAs(s.configFile) } func validateURL(u string) error { diff --git a/apps/cliq-hub-backend/cmd/server/main.go b/apps/cliq-hub-backend/cmd/server/main.go index 60a8a67..013a169 100644 --- a/apps/cliq-hub-backend/cmd/server/main.go +++ b/apps/cliq-hub-backend/cmd/server/main.go @@ -1,37 +1,37 @@ package main import ( - "log" - "net/http" - "os" + "log" + "net/http" + "os" - "cliq-hub-backend/internal/config" - "cliq-hub-backend/internal/http/router" - "cliq-hub-backend/internal/llm" + "cliq-hub-backend/internal/config" + "cliq-hub-backend/internal/http/router" + "cliq-hub-backend/internal/llm" ) func main() { - cfg, err := config.Load() - if err != nil { - log.Fatalf("config error: %v", err) - } + cfg, err := config.Load() + if err != nil { + log.Fatalf("config error: %v", err) + } - client, err := llm.NewClient(cfg) - if err != nil { - log.Fatalf("llm client init error: %v", err) - } + client, err := llm.NewClient(cfg) + if err != nil { + log.Fatalf("llm client init error: %v", err) + } - debugMode := os.Getenv("GIN_MODE") != "release" - r := router.New(client, debugMode) + debugMode := os.Getenv("GIN_MODE") != "release" + r := router.New(client, debugMode) - port := os.Getenv("PORT") - if port == "" { - port = "8080" - } + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } - srv := &http.Server{Addr: ":" + port, Handler: r} - log.Printf("server listening on :%s", port) - if err := srv.ListenAndServe(); err != nil && err.Error() != "http: Server closed" { - log.Fatalf("server error: %v", err) - } -} \ No newline at end of file + srv := &http.Server{Addr: ":" + port, Handler: r} + log.Printf("server listening on :%s", port) + if err := srv.ListenAndServe(); err != nil && err.Error() != "http: Server closed" { + log.Fatalf("server error: %v", err) + } +} diff --git a/apps/cliq-hub-backend/internal/config/config.go b/apps/cliq-hub-backend/internal/config/config.go index f8684ac..426ee2f 100644 --- a/apps/cliq-hub-backend/internal/config/config.go +++ b/apps/cliq-hub-backend/internal/config/config.go @@ -1,27 +1,27 @@ package config import ( - "errors" - "os" + "errors" + "os" ) type Config struct { - LLMBaseURL string - LLMAPIKey string - LLMModel string + LLMBaseURL string + LLMAPIKey string + LLMModel string } func Load() (*Config, error) { - cfg := &Config{ - LLMBaseURL: os.Getenv("LLM_BASE_URL"), - LLMAPIKey: os.Getenv("LLM_API_KEY"), - LLMModel: os.Getenv("LLM_MODEL"), - } - if cfg.LLMAPIKey == "" { - return nil, errors.New("LLM_API_KEY is required") - } - if cfg.LLMModel == "" { - return nil, errors.New("LLM_MODEL is required") - } - return cfg, nil -} \ No newline at end of file + cfg := &Config{ + LLMBaseURL: os.Getenv("LLM_BASE_URL"), + LLMAPIKey: os.Getenv("LLM_API_KEY"), + LLMModel: os.Getenv("LLM_MODEL"), + } + if cfg.LLMAPIKey == "" { + return nil, errors.New("LLM_API_KEY is required") + } + if cfg.LLMModel == "" { + return nil, errors.New("LLM_MODEL is required") + } + return cfg, nil +} diff --git a/apps/cliq-hub-backend/internal/errors/api.go b/apps/cliq-hub-backend/internal/errors/api.go index ded95e0..ba71406 100644 --- a/apps/cliq-hub-backend/internal/errors/api.go +++ b/apps/cliq-hub-backend/internal/errors/api.go @@ -1,19 +1,19 @@ package errors type APIError struct { - Error string `json:"error"` - Message string `json:"message"` - Meta map[string]interface{} `json:"meta,omitempty"` + Error string `json:"error"` + Message string `json:"message"` + Meta map[string]interface{} `json:"meta,omitempty"` } func New(code, msg string) APIError { - return APIError{Error: code, Message: msg} + return APIError{Error: code, Message: msg} } func (e APIError) WithMeta(key string, value interface{}) APIError { - if e.Meta == nil { - e.Meta = make(map[string]interface{}) - } - e.Meta[key] = value - return e -} \ No newline at end of file + if e.Meta == nil { + e.Meta = make(map[string]interface{}) + } + e.Meta[key] = value + return e +} diff --git a/apps/cliq-hub-backend/internal/template/model.go b/apps/cliq-hub-backend/internal/template/model.go index 34890cc..d339a9c 100644 --- a/apps/cliq-hub-backend/internal/template/model.go +++ b/apps/cliq-hub-backend/internal/template/model.go @@ -1,26 +1,26 @@ package template type Template struct { - Name string `yaml:"name"` - Description string `yaml:"description"` - Version string `yaml:"version"` - Author string `yaml:"author"` - CliqTemplateVersion string `yaml:"cliq_template_version"` - Cmds []Cmd `yaml:"cmds"` + Name string `yaml:"name"` + Description string `yaml:"description"` + Version string `yaml:"version"` + Author string `yaml:"author"` + CliqTemplateVersion string `yaml:"cliq_template_version"` + Cmds []Cmd `yaml:"cmds"` } type Cmd struct { - Name string `yaml:"name"` - Description string `yaml:"description"` - Command string `yaml:"command"` - Variables []Variable `yaml:"variables"` + Name string `yaml:"name"` + Description string `yaml:"description"` + Command string `yaml:"command"` + Variables []Variable `yaml:"variables"` } type Variable struct { - Name string `yaml:"name"` - Type string `yaml:"type"` - Label string `yaml:"label"` - Description string `yaml:"description"` - Required bool `yaml:"required"` - Options map[string]interface{} `yaml:"options,omitempty"` -} \ No newline at end of file + Name string `yaml:"name"` + Type string `yaml:"type"` + Label string `yaml:"label"` + Description string `yaml:"description"` + Required bool `yaml:"required"` + Options map[string]interface{} `yaml:"options,omitempty"` +} diff --git a/apps/cliq-hub-backend/internal/version/version.go b/apps/cliq-hub-backend/internal/version/version.go index 365277d..c596bea 100644 --- a/apps/cliq-hub-backend/internal/version/version.go +++ b/apps/cliq-hub-backend/internal/version/version.go @@ -1,6 +1,6 @@ package version const ( - TemplateVersion = "1.0" - CliqTemplateSpecVersion = "1.0" -) \ No newline at end of file + TemplateVersion = "1.0" + CliqTemplateSpecVersion = "1.0" +) diff --git a/packages/cliqfile/validator_test.go b/packages/cliqfile/validator_test.go index aaa4258..5a38dc2 100644 --- a/packages/cliqfile/validator_test.go +++ b/packages/cliqfile/validator_test.go @@ -52,13 +52,13 @@ func TestValidateRoot(t *testing.T) { expectedError string }{ { - name: "Empty document", - yaml: "", + name: "Empty document", + yaml: "", expectedError: "Empty document", }, { - name: "Root not a mapping", - yaml: "- item1", + name: "Root not a mapping", + yaml: "- item1", expectedError: "Root must be a mapping (object)", }, { @@ -326,7 +326,7 @@ cmds: } func TestValidateVariableUsage(t *testing.T) { - yamlStr := ` + yamlStr := ` name: Test description: Test version: 1.0 @@ -341,28 +341,28 @@ cmds: type: string label: Defined ` - errors, err := Validate([]byte(yamlStr)) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } - foundUnused := false - foundUndefined := false + errors, err := Validate([]byte(yamlStr)) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + foundUnused := false + foundUndefined := false - for _, e := range errors { - if e.Field == "command" && e.Message == "Variable 'unused_var' used in command string but not defined in variables" { - foundUndefined = true - } - if e.Field == "variables" && e.Message == "Variable 'defined_var' defined but not used in command string" { - foundUnused = true - } - } + for _, e := range errors { + if e.Field == "command" && e.Message == "Variable 'unused_var' used in command string but not defined in variables" { + foundUndefined = true + } + if e.Field == "variables" && e.Message == "Variable 'defined_var' defined but not used in command string" { + foundUnused = true + } + } - if !foundUndefined { - t.Error("Expected error about undefined variable usage") - } - if !foundUnused { - t.Error("Expected error about unused variable definition") - } + if !foundUndefined { + t.Error("Expected error about undefined variable usage") + } + if !foundUnused { + t.Error("Expected error about unused variable definition") + } } func TestValidateNoVariables(t *testing.T) { @@ -385,8 +385,8 @@ cmds: t.Errorf("Expected no errors, got %v", errors) } - // Also test with variables: [] - validYAML2 := ` + // Also test with variables: [] + validYAML2 := ` name: My Template description: A description version: 1.0