Skip to content

Commit

Permalink
refactor: Refactor error handling and variable declaration for better…
Browse files Browse the repository at this point in the history
… code clarity.
  • Loading branch information
moonD4rk committed Apr 26, 2023
1 parent aba28e8 commit 6918d1b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
goVer: [1.18.x]
goVer: ["1.20"]

steps:
- name: Set up Go ${{ matrix.goVer }}
Expand Down
7 changes: 4 additions & 3 deletions notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ func New(options ...Option) *Notifier {
return n
}

var ErrSendNotification = errors.New("send notification")
var ErrNoProvider = errors.New("no provider, please check your config")
var (
ErrSendNotification = errors.New("send notification")
ErrNoProvider = errors.New("no provider, please check your config")
)

func (n *Notifier) Send(subject, content string) error {
if len(n.Providers) == 0 {
Expand All @@ -33,7 +35,6 @@ func (n *Notifier) Send(subject, content string) error {
})
}
err := eg.Wait()

if err != nil {
err = errors.Join(ErrSendNotification, err)
}
Expand Down
4 changes: 1 addition & 3 deletions provider/serverchan/serverchan.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ func New(userID, sendKey string) *Provider {
}

func (p *Provider) Send(subject, content string) error {
var (
defaultServer = "sctapi.ftqq.com"
)
defaultServer := "sctapi.ftqq.com"
url := fmt.Sprintf("https://%s/%s.send", defaultServer, p.SendKey)
type postData struct {
Text string `json:"text"`
Expand Down

0 comments on commit 6918d1b

Please sign in to comment.