Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oho/cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func init() {
Cmd.AddCommand(setCmd)

setCmd.Flags().StringArrayVar(&credentials, "credentials", nil, "认证凭据 (key=value 格式)")
setCmd.MarkFlagRequired("credentials")
_ = setCmd.MarkFlagRequired("credentials")
}

func indexOf(s string, substr string) int {
Expand Down
2 changes: 1 addition & 1 deletion oho/cmd/configcmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PORT", "4096")
os.Setenv("OPENCODE_SERVER_USERNAME", "opencode")
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")
config.Init()
_ = config.Init()

m.Run()
}
Expand Down
2 changes: 1 addition & 1 deletion oho/cmd/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PORT", "4096")
os.Setenv("OPENCODE_SERVER_USERNAME", "opencode")
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")
config.Init()
_ = config.Init()

m.Run()
}
Expand Down
4 changes: 2 additions & 2 deletions oho/cmd/global/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PORT", "4096")
os.Setenv("OPENCODE_SERVER_USERNAME", "opencode")
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")
config.Init()
_ = config.Init()

m.Run()
}
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestHealthCmd(t *testing.T) {
server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(tt.serverStatus)
if tt.serverResponse != nil {
json.NewEncoder(w).Encode(tt.serverResponse)
_ = json.NewEncoder(w).Encode(tt.serverResponse)
}
}))
defer server.Close()
Expand Down
2 changes: 1 addition & 1 deletion oho/cmd/mcp/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ func init() {
Cmd.AddCommand(addCmd)

addCmd.Flags().StringVar(&mcpConfig, "config", "", "MCP 服务器配置 (JSON 格式)")
addCmd.MarkFlagRequired("config")
_ = addCmd.MarkFlagRequired("config")
}
6 changes: 3 additions & 3 deletions oho/cmd/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var (
noReply bool
systemPrompt string
tools []string
asyncMode bool
commandName string
// asyncMode bool // unused
// commandName string // unused
commandArgs []string
shellCommand string
)
Expand All @@ -44,7 +44,7 @@ func init() {

// 全局标志
Cmd.PersistentFlags().StringVarP(&sessionID, "session", "s", "", "会话 ID")
Cmd.MarkPersistentFlagRequired("session")
_ = Cmd.MarkPersistentFlagRequired("session")
}

// listCmd 列出消息
Expand Down
2 changes: 1 addition & 1 deletion oho/cmd/message/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PORT", "4096")
os.Setenv("OPENCODE_SERVER_USERNAME", "opencode")
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")
config.Init()
_ = config.Init()

m.Run()
}
Expand Down
12 changes: 2 additions & 10 deletions oho/cmd/session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package session
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"os"
"testing"

Expand All @@ -19,7 +17,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PORT", "4096")
os.Setenv("OPENCODE_SERVER_USERNAME", "opencode")
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")
config.Init()
_ = config.Init()

m.Run()
}
Expand Down Expand Up @@ -455,10 +453,4 @@ func TestSessionPermissionsCmd(t *testing.T) {
}
}

func createTestServer(handlers map[string]http.HandlerFunc) *httptest.Server {
mux := http.NewServeMux()
for path, handler := range handlers {
mux.Handle(path, handler)
}
return httptest.NewServer(mux)
}

4 changes: 2 additions & 2 deletions oho/cmd/tool/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ func init() {

listCmd.Flags().StringVar(&providerID, "provider", "", "提供商 ID")
listCmd.Flags().StringVar(&modelID, "model", "", "模型 ID")
listCmd.MarkFlagRequired("provider")
listCmd.MarkFlagRequired("model")
_ = listCmd.MarkFlagRequired("provider")
_ = listCmd.MarkFlagRequired("model")
}
8 changes: 4 additions & 4 deletions oho/cmd/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
message string
variant string
command string
controlID string
// controlID string // unused
body string

appendPromptCmd = &cobra.Command{
Expand Down Expand Up @@ -325,11 +325,11 @@ func init() {
showToastCmd.Flags().StringVar(&title, "title", "", "消息标题")
showToastCmd.Flags().StringVar(&message, "message", "", "消息内容")
showToastCmd.Flags().StringVar(&variant, "variant", "info", "消息类型 (info/warning/error/success)")
showToastCmd.MarkFlagRequired("message")
_ = showToastCmd.MarkFlagRequired("message")

executeCommandCmd.Flags().StringVar(&command, "command", "", "要执行的命令")
executeCommandCmd.MarkFlagRequired("command")
_ = executeCommandCmd.MarkFlagRequired("command")

controlResponseCmd.Flags().StringVar(&body, "body", "", "响应体 (JSON 格式)")
controlResponseCmd.MarkFlagRequired("body")
_ = controlResponseCmd.MarkFlagRequired("body")
}
2 changes: 1 addition & 1 deletion oho/internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestClientGetSuccess(t *testing.T) {
t.Errorf("Expected GET, got %s", r.Method)
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
_ = json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
}))
defer server.Close()

Expand Down
2 changes: 1 addition & 1 deletion oho/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Init() error {
cfg.Host = envHost
}
if envPort := os.Getenv("OPENCODE_SERVER_PORT"); envPort != "" {
fmt.Sscanf(envPort, "%d", &cfg.Port)
_, _ = fmt.Sscanf(envPort, "%d", &cfg.Port)
}
if envUsername := os.Getenv("OPENCODE_SERVER_USERNAME"); envUsername != "" {
cfg.Username = envUsername
Expand Down
2 changes: 1 addition & 1 deletion oho/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")

// 初始化配置
Init()
_ = Init()

m.Run()
}
4 changes: 2 additions & 2 deletions oho/internal/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,15 @@ func MockBoolResponse(b bool) []byte {
func ErrorHandler(statusCode int, message string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(statusCode)
w.Write([]byte(message))
_, _ = w.Write([]byte(message))
}
}

// JSONHandler 创建 JSON 响应处理器
func JSONHandler(v interface{}) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(v)
_ = json.NewEncoder(w).Encode(v)
}
}

Expand Down
4 changes: 2 additions & 2 deletions oho/internal/util/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func OutputTable(headers []string, rows [][]string) {
}
data[i] = rowMap
}
OutputJSON(data)
_ = OutputJSON(data)
return
}

Expand Down Expand Up @@ -97,7 +97,7 @@ func Confirm(prompt string) bool {

fmt.Printf("%s [y/N]: ", prompt)
var response string
fmt.Scanln(&response)
_, _ = fmt.Scanln(&response)
return strings.ToLower(response) == "y" || strings.ToLower(response) == "yes"
}

Expand Down
2 changes: 1 addition & 1 deletion oho/internal/util/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestMain(m *testing.M) {
os.Setenv("OPENCODE_SERVER_PORT", "4096")
os.Setenv("OPENCODE_SERVER_USERNAME", "opencode")
os.Setenv("OPENCODE_SERVER_PASSWORD", "test")
config.Init()
_ = config.Init()

m.Run()
}
Expand Down
Loading