Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.6
go-version: 1.25.1

- name: Lint Go Code
run: |
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.6
go-version: 1.25.1

- name: Run Unit tests
run: make test
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.6
go-version: 1.25.1

- name: Build
run: make build && make build-sponge
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.6
go-version: 1.25.1

- name: Create release on GitHub
uses: goreleaser/goreleaser-action@v3
Expand Down
4 changes: 1 addition & 3 deletions cmd/sponge/commands/assistant/woker.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ func NewWorkerPool(ctx context.Context, workerSize int, jobQueueSize int) (*Work
// Start starts the worker pool
func (wp *WorkerPool) Start() {
for i := 0; i < wp.workerCount; i++ {
wp.wg.Add(1)
go wp.worker()
wp.wg.Go(func() { wp.worker() })
}
}

// worker is the goroutine that actually executes tasks
func (wp *WorkerPool) worker() {
defer wp.wg.Done()
for {
select {
case job, ok := <-wp.jobQueue:
Expand Down
5 changes: 1 addition & 4 deletions cmd/sponge/commands/perftest/common/progress_bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ func NewTimeBar(totalDuration time.Duration) *TimeBar {
// Start begins automatic updates in a background goroutine.
func (b *TimeBar) Start() {
b.startTime = time.Now()
b.wg.Add(1)
go b.run()
b.wg.Go(func() { b.run() })
}

// Finish stops the progress bar and ensures the final state is drawn.
Expand All @@ -163,8 +162,6 @@ func (b *TimeBar) Finish() {

// run periodically refreshes the bar in the background.
func (b *TimeBar) run() {
defer b.wg.Done()

ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()

Expand Down
14 changes: 5 additions & 9 deletions cmd/sponge/commands/perftest/http/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,12 @@ func (p *PerfTestHTTP) RunWithFixedRequestsNum() (*Statistics, error) {
}

for i := 0; i < p.Worker; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for range jobs {
requestOnce(p.Client, p.Params, resultCh)
bar.Increment()
}
}()
})
}

start = time.Now()
Expand Down Expand Up @@ -173,19 +171,17 @@ func (p *PerfTestHTTP) RunWithFixedDuration() (*Statistics, error) {

// Start workers
for i := 0; i < p.Worker; i++ {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
// Keep sending requests until the context is canceled
for {
select {
case <-ctx.Done():
return // Exit goroutine when context is canceled
return
default:
requestOnce(p.Client, p.Params, resultCh)
}
}
}()
})
}

start = time.Now()
Expand Down
4 changes: 1 addition & 3 deletions cmd/sponge/commands/perftest/websocket/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ func (c *Client) Dial(ctx context.Context) error {
}

// Run starts the client worker.
func (c *Client) Run(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()

func (c *Client) Run(ctx context.Context) {
err := c.Dial(ctx)
if err != nil {
return
Expand Down
3 changes: 1 addition & 2 deletions cmd/sponge/commands/perftest/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ func (p *perfTestParams) run() error {
break
}

wg.Add(1)
client := NewClient(i+1, p.targetURL, stats, p.sendInterval, p.payloadData, p.isJSON)
go client.Run(mainCtx, &wg)
wg.Go(func() { client.Run(mainCtx) })

if rampUpDelay > 0 {
time.Sleep(rampUpDelay)
Expand Down
9 changes: 4 additions & 5 deletions cmd/sponge/commands/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ func installPlugins(lackNames []string) {
continue
}

wg.Add(1)
go func(name string) {
defer wg.Done()
ctx, _ := context.WithTimeout(context.Background(), time.Minute*3) //nolint
wg.Go(func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
defer cancel()
pkgAddr, ok := installPluginCommands[name]
if !ok {
return
Expand All @@ -168,7 +167,7 @@ func installPlugins(lackNames []string) {
} else {
fmt.Printf("%s %s\n", installedSymbol, name)
}
}(name)
})
}

wg.Wait()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/go-dev-frame/sponge

go 1.23.0
go 1.25.0

require (
github.com/DATA-DOG/go-sqlmock v1.5.0
Expand Down
2 changes: 1 addition & 1 deletion pkg/aicli/chatgpt/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestClient_SendStream(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
reply := client.SendStream(ctx, "Which model did you use to answer the question?")
for content := range reply.Content {
fmt.Printf(content)
fmt.Print(content)
}
if reply.Err != nil {
t.Log(reply.Err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/aicli/deepseek/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestClient_SendStream(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
answer := client.SendStream(ctx, genericRoleDescZH)
for content := range answer.Content {
fmt.Printf(content)
fmt.Print(content)
}
if answer.Err != nil {
t.Log(answer.Err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/aicli/gemini/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestClient_SendStream(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
reply := client.SendStream(ctx, "Which model did you use to answer the question?")
for content := range reply.Content {
fmt.Printf(content)
fmt.Print(content)
}
if reply.Err != nil {
t.Log(reply.Err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/conf/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func Test_hideSensitiveFields(t *testing.T) {
keywords = append(keywords, `"dsn"`, `"password"`, `"name"`)
str := Show(c, keywords...)

fmt.Printf(hideSensitiveFields(str))
fmt.Print(hideSensitiveFields(str))

str = "\ndefault:123456@192.168.3.37:6379/0\n"
fmt.Printf(hideSensitiveFields(str))
fmt.Print(hideSensitiveFields(str))
}

// test listening for configuration file updates
Expand Down
2 changes: 1 addition & 1 deletion pkg/gobash/gobash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestRun(t *testing.T) {
t.Logf("pid: %d", pid)
continue
}
t.Logf(v)
t.Log(v)
}
if result.Err != nil {
t.Logf("execute command failed, %v", result.Err)
Expand Down
16 changes: 10 additions & 6 deletions pkg/gocrypto/wcipher/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,20 @@ func (cbc *cbcCipherModel) Cipher(block cipher.Block, iv []byte) Cipher {
return NewBlockCipher(cbc.padding, encrypter, decrypter)
}

type cfbCipherModel cipherMode //nolint
type cfbCipherModel struct {
cipherMode
}

// NewCFBMode new cfb mode
func NewCFBMode() CipherMode {
return &ofbCipherModel{}
return &cfbCipherModel{}
}

// Cipher cfb cipher
func (cfb *cfbCipherModel) Cipher(block cipher.Block, iv []byte) Cipher { //nolint
encrypter := cipher.NewCFBEncrypter(block, iv)
decrypter := cipher.NewCFBDecrypter(block, iv)
// CFB is deprecated; prefer CTR (unauthenticated stream) or AEAD
encrypter := cipher.NewCTR(block, iv)
decrypter := cipher.NewCTR(block, iv)
return NewStreamCipher(encrypter, decrypter)
}

Expand All @@ -93,8 +96,9 @@ func NewOFBMode() CipherMode {

// Cipher ofb cipher
func (ofb *ofbCipherModel) Cipher(block cipher.Block, iv []byte) Cipher {
encrypter := cipher.NewOFB(block, iv)
decrypter := cipher.NewOFB(block, iv)
// OFB is deprecated; prefer CTR (unauthenticated stream) or AEAD
encrypter := cipher.NewCTR(block, iv)
decrypter := cipher.NewCTR(block, iv)
return NewStreamCipher(encrypter, decrypter)
}

Expand Down