Skip to content

Commit

Permalink
Remove slog
Browse files Browse the repository at this point in the history
  • Loading branch information
jjti committed Jan 2, 2024
1 parent 9a6c631 commit 4b9fde7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [main]

env:
GO_VERSION: ^1.21
GO_VERSION: ^1.20
GOLANGCI_LINT_VERSION: v1.55.0

jobs:
Expand Down
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package spancheck
import (
"flag"
"fmt"
"log/slog"
"log"
"regexp"
"strings"
)
Expand Down Expand Up @@ -116,7 +116,7 @@ func createRegex(sigs []string) *regexp.Regexp {
regex := fmt.Sprintf("(%s)", strings.Join(sigs, "|"))
regexCompiled, err := regexp.Compile(regex)
if err != nil {
slog.Warn("failed to compile regex from signature flag", "regex", regex, "err", err)
log.Default().Print("[WARN] failed to compile regex from signature flag", "regex", regex, "err", err)
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions spancheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"go/parser"
"go/token"
"go/types"
"log/slog"
"log"
"regexp"
"strings"

Expand Down Expand Up @@ -319,7 +319,7 @@ outer:
}
}
if defBlock == nil {
slog.Error("internal error: can't find defining block for span var")
log.Default().Print("[ERROR] internal error: can't find defining block for span var")
}

// Is the call "used" in the remainder of its defining block?
Expand Down Expand Up @@ -427,19 +427,19 @@ func isErrorType(t types.Type) bool {
// copied out of the internal go util: https://github.com/golang/tools/blob/master/internal/analysisinternal/extractdoc.go
func extractDoc(content, name string) string {
if content == "" {
slog.Warn("empty content")
log.Default().Print("[WARN] empty content")
return ""
}

fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "", content, parser.ParseComments|parser.PackageClauseOnly)
if err != nil {
slog.Warn("failed to parse doc.go", err)
log.Default().Print("[WARN] failed to parse doc.go", err)
return ""
}

if f.Doc == nil {
slog.Warn("no package doc comment")
log.Default().Print("[WARN] no package doc comment")
return ""
}

Expand All @@ -450,12 +450,12 @@ func extractDoc(content, name string) string {
body = strings.TrimSpace(body)
rest := strings.TrimPrefix(body, name+":")
if rest == body {
slog.Warn("package doc comment contains no '" + name + "' heading")
log.Default().Print("[ERROR] package doc comment contains no '" + name + "' heading")
}
return strings.TrimSpace(rest)
}
}

slog.Warn("package doc comment contains no 'Analyzer " + name + "' heading")
log.Default().Print("[ERROR] package doc comment contains no 'Analyzer " + name + "' heading")
return ""
}

0 comments on commit 4b9fde7

Please sign in to comment.