Skip to content

Commit 4a1c56f

Browse files
committed
fix:golangci-lint
1 parent 6ef29bc commit 4a1c56f

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

examples/email/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
}
4343

4444
if err := chat.run(); err != nil {
45-
log.Fatal("Chat failed: %v", err)
45+
log.Fatalf("Chat failed: %s", err.Error())
4646
}
4747
}
4848

@@ -68,7 +68,7 @@ func (c *emailChat) run() error {
6868
}
6969

7070
// setup creates the runner with LLM agent and send email tool.
71-
func (c *emailChat) setup(ctx context.Context) error {
71+
func (c *emailChat) setup(_ context.Context) error {
7272
// Create OpenAI model.
7373
modelInstance := openai.New(c.modelName)
7474

tool/email/email.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ const (
2525
type MailboxType int32
2626

2727
const (
28-
// unknown mail
28+
// MAIL_UNKNOWN unknown mail
2929
MAIL_UNKNOWN MailboxType = 0
30-
// qq mail
30+
// MAIL_QQ qq mail
3131
MAIL_QQ MailboxType = 1
32-
// 163 mail
32+
// MAIL_163 163 mail
3333
MAIL_163 MailboxType = 2
34-
// google mail
34+
// MAIL_GMAIL google mail
3535
MAIL_GMAIL MailboxType = 3
3636
)
3737

@@ -77,7 +77,7 @@ type emailToolSet struct {
7777
}
7878

7979
// Tools implements the ToolSet interface.
80-
func (e *emailToolSet) Tools(ctx context.Context) []tool.Tool {
80+
func (e *emailToolSet) Tools(_ context.Context) []tool.Tool {
8181
return e.tools
8282
}
8383

tool/email/sendmail.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ type sendMailResponse struct {
3434
}
3535

3636
// sendMail performs the send mail operation.
37-
func (e *emailToolSet) sendMail(ctx context.Context, req *sendMailRequest) (rsp *sendMailResponse, err error) {
37+
// go smtp not support context, one send one mail, can't stop
38+
func (e *emailToolSet) sendMail(_ context.Context, req *sendMailRequest) (rsp *sendMailResponse, err error) {
3839
rsp = &sendMailResponse{}
3940

4041
mailBoxType, err := checkMailBoxType(req.Auth.Name)
@@ -64,9 +65,11 @@ func (e *emailToolSet) sendMail(ctx context.Context, req *sendMailRequest) (rsp
6465
s, err := dialer.Dial()
6566
if err != nil {
6667
rsp.Message = fmt.Sprintf("the address or password is incorrect,please check: %v", err)
67-
return rsp, fmt.Errorf("the address or password is incorrect,please check: %w", err)
68+
return rsp, nil
6869
}
69-
defer s.Close()
70+
defer func() {
71+
_ = s.Close()
72+
}()
7073

7174
message := gomail.NewMessage()
7275
for _, m := range req.MailList {

0 commit comments

Comments
 (0)