837 matches across 25 files for error lang:Go lang:Go lang:Go lang:Go
snippet_mode: grep · sorted by relevance
cmd/badges/main.go GO 12 matches · showing 5 view file →
3import (
4 "context"
5 "errors"
6 "fmt"
7 "math"
· · ·
63
64 if filterBad(loc) {
65 log.Error().Str(uniqueCode, "bfee4bd8").Str("loc", loc.String()).Msg("filter bad")
66 return
67 }
· · ·
71 res, err := process(1, loc)
72 if err != nil {
73 log.Error().Str(uniqueCode, "03ec75c3").Err(err).Str("loc", loc.String()).Send()
74 w.WriteHeader(http.StatusBadRequest)
75 _, _ = w.Write([]byte("something bad happened sorry"))
· · ·
108 addr := ":8080"
109 log.Info().Str(uniqueCode, "1876ce1e").Str("addr", addr).Msg("serving")
110 if err := http.ListenAndServe(addr, nil); err != nil && !errors.Is(err, http.ErrServerClosed) {
111 log.Error().Str(uniqueCode, "c28556e8").Err(err).Send()
112 os.Exit(1)
· · ·
111 log.Error().Str(uniqueCode, "c28556e8").Err(err).Send()
112 os.Exit(1)
113 }
+ 7 more matches in this file
cmd/badges/main_test.go GO 5 matches view file →
57 t.Run(tt.name, func(t *testing.T) {
58 if got := resolveColor(tt.color); got != tt.want {
59 t.Errorf("resolveColor(%q) = %q, want %q", tt.color, got, tt.want)
60 }
61 })
· · ·
125 t.Run(tt.name, func(t *testing.T) {
126 if got := formatCount(tt.args.count); got != tt.want {
127 t.Errorf("formatCount() = %v, want %v", got, tt.want)
128 }
129 })
· · ·
170 got, err := processUrlPath(tt.args.path)
171 if (err != nil) != tt.wantErr {
172 t.Errorf("processUrlPath() error = %v, wantErr %v", err, tt.wantErr)
173 return
174 }
· · ·
175 if !reflect.DeepEqual(got, tt.want) {
176 t.Errorf("processUrlPath() got = %v, want %v", got, tt.want)
177 }
178 })
· · ·
298 t.Run(tt.name, func(t *testing.T) {
299 if got := parseBadgeSettings(tt.values); !reflect.DeepEqual(got, tt.want) {
300 t.Errorf("parseBadgeSettings() = %v, want %v", got, tt.want)
301 }
302 })
main.go GO 8 matches · showing 5 view file →
4
5import (
6 "errors"
7 "fmt"
8 "os"
· · ·
16)
17
18func printShellCompletion(cmd *cobra.Command, command string) error {
19 switch command {
20 case "bash":
· · ·
27 return cmd.GenPowerShellCompletion(os.Stdout)
28 default:
29 return errors.New("Unknown shell: " + command)
30 }
31}
· · ·
65 b, err := os.ReadFile(filepath)
66 if err != nil {
67 fmt.Printf("Error reading flags from a file: %s\n", err)
68 os.Exit(1)
69 }
· · ·
642 err := printShellCompletion(rootCmd, args[3])
643 if err != nil {
644 _, _ = fmt.Fprintf(os.Stderr, "Error printing shell completion: %s\n", err)
645 }
646 return
+ 3 more matches in this file
main_test.go GO 33 matches · showing 5 view file →
29}
30
31func runSCC(args ...string) (string, error) {
32 args = slices.Insert(args, 0, sccTestFlag)
33 cmd := exec.Command(sccBinPath, args...)
· · ·
265 }
266 if !strings.Contains(output, "MATLAB") {
267 t.Errorf("can not find MATLAB, output: %s", output)
268 }
269 if !strings.Contains(output, "Objective C") {
· · ·
270 t.Errorf("can not find Objective C, output:\n%s", output)
271 }
272}
· · ·
276 output, err := runSCC("--not-a-real-option")
277 if err == nil {
278 t.Fatal("scc should exit with error code")
279 }
280 if !strings.Contains(output, "Error: unknown flag: --not-a-real-option") {
· · ·
280 if !strings.Contains(output, "Error: unknown flag: --not-a-real-option") {
281 t.Fatalf("scc should report invalid options, output:\n%s", output)
282 }
+ 28 more matches in this file
mcp.go GO 8 matches · showing 5 view file →
81
82 errLogger := log.New(os.Stderr, "scc-mcp: ", log.LstdFlags)
83 if err := server.ServeStdio(mcpServer, server.WithErrorLogger(errLogger)); err != nil {
84 _, _ = fmt.Fprintf(os.Stderr, "scc-mcp: server error: %v\n", err)
85 os.Exit(1)
· · ·
84 _, _ = fmt.Fprintf(os.Stderr, "scc-mcp: server error: %v\n", err)
85 os.Exit(1)
86 }
· · ·
149}
150
151func mcpAnalyzeHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
152 args := request.GetArguments()
153
· · ·
161 absPath, err := filepath.Abs(path)
162 if err != nil {
163 return mcp.NewToolResultError(fmt.Sprintf("invalid path: %v", err)), nil
164 }
165
· · ·
166 // Verify path can be accessed
167 if _, err := os.Stat(absPath); err != nil {
168 return mcp.NewToolResultError(fmt.Sprintf("path cannot be accessed: %s: %v", absPath, err)), nil
169 }
170
+ 3 more matches in this file
processor/cocomo_test.go GO 3 matches view file →
13 // Should be around 582
14 if got < 580 || got > 585 {
15 t.Errorf("Got %f", got)
16 }
17}
· · ·
23 // Should be around 2602096
24 if got < 2602000 || got > 2602100 {
25 t.Errorf("Got %f", got)
26 }
27}
· · ·
33 // Should be around 2.7
34 if got < 2.6 || got > 2.8 {
35 t.Errorf("Got %f", got)
36 }
37}
processor/constants.go GO 1 matches view file →
626 "else if ",
627 "try ",
628 "on error ",
629 "and ",
630 "or ",
processor/detector.go GO 7 matches · showing 5 view file →
6 "bytes"
7 "cmp"
8 "errors"
9 "slices"
10 "strings"
· · ·
12
13var (
14 errMissingShebang = errors.New("missing shebang")
15 errUnknownShebang = errors.New("unknown shebang")
16 errUnableToDetermineShebangCmd = errors.New("unable to determine shebang command")
· · ·
15 errUnknownShebang = errors.New("unknown shebang")
16 errUnableToDetermineShebangCmd = errors.New("unable to determine shebang command")
17)
· · ·
16 errUnableToDetermineShebangCmd = errors.New("unable to determine shebang command")
17)
18
· · ·
19// DetectLanguage detects a language based on the filename returns the language extension and error
20func DetectLanguage(name string) ([]string, string) {
21 extension := ""
+ 2 more matches in this file
processor/detector_test.go GO 37 matches · showing 5 view file →
15
16 if ext != "css" {
17 t.Error("Expected css got", ext)
18 }
19 AllowListExtensions = []string{}
· · ·
26
27 if x != "" || y == nil {
28 t.Error("Expected no match got", x)
29 }
30
· · ·
32
33 if x != "" || y == nil {
34 t.Error("Expected no match got", x)
35 }
36}
· · ·
55
56 if x != "Perl" || y != nil {
57 t.Error("Expected Perl match got", x, "for", c)
58 }
59 }
· · ·
72
73 if x != "PHP" || y != nil {
74 t.Error("Expected PHP match got", x)
75 }
76 }
+ 32 more matches in this file
processor/file.go GO 3 matches view file →
66 }
67
68 var err error
69 symPath, err = filepath.EvalSymlinks(path)
70 if err != nil {
· · ·
71 printError(err.Error())
72 return nil
73 }
· · ·
74 fileInfo, err = os.Lstat(symPath)
75 if err != nil {
76 printError(err.Error())
77 return nil
78 }
processor/file_test.go GO 19 matches · showing 5 view file →
16
17 if got != expected {
18 t.Errorf("Expected %s got %s", expected, got)
19 }
20}
· · ·
25
26 if got != expected {
27 t.Errorf("Expected %s got %s", expected, got)
28 }
29}
· · ·
34
35 if got != expected {
36 t.Errorf("Expected %s got %s", expected, got)
37 }
38}
· · ·
43
44 if got != expected {
45 t.Errorf("Expected %s got %s", expected, got)
46 }
47}
· · ·
52
53 if got != expected {
54 t.Errorf("Expected %s got %s", expected, got)
55 }
56}
+ 14 more matches in this file
processor/filereader.go GO 3 matches view file →
23
24// ReadFile actually reads the file into a buffer size controlled by LargeByteCount
25func (reader *FileReader) ReadFile(path string, size int) ([]byte, error) {
26 fd, err := os.Open(path)
27 if err != nil {
· · ·
28 return nil, fmt.Errorf("error opening %s: %v", path, err)
29 }
30 defer func(file *os.File) {
· · ·
48 _, err = io.Copy(reader.Buffer, fd)
49 if err != nil {
50 return nil, fmt.Errorf("error reading %s: %v", path, err)
51 }
52
processor/formatters_test.go GO 98 matches · showing 5 view file →
18
19 if !strings.Contains(str.String(), "Estimated Schedule Effort (organic) 0.22 months") {
20 t.Error("expected to match got", str.String())
21 }
22}
· · ·
27
28 if !strings.Contains(str.String(), "Processed 1 bytes, 0.000 megabytes (SI)") {
29 t.Error("expected to match got", str.String())
30 }
31}
· · ·
36
37 if !strings.Contains(str.String(), "Processed 1000000 bytes, 1.000 megabytes (SI)") {
38 t.Error("expected to match got", str.String())
39 }
40}
· · ·
95
96 if summary.Files[0].Filename != "aaaa.go" {
97 t.Error("Sorting on lines failed", val)
98 }
99 }
· · ·
105
106 if summary.Files[0].Filename != "aaaa.go" {
107 t.Error("Sorting on blank failed", val)
108 }
109 }
+ 93 more matches in this file
processor/helpers_test.go GO 2 matches view file →
13
14 if res == makeTimestampNano() {
15 t.Error("Should not match")
16 }
17}
· · ·
22
23 if res == makeTimestampMilli() {
24 t.Error("Should not match")
25 }
26}
processor/history.go GO 17 matches · showing 5 view file →
5import (
6 "context"
7 "errors"
8 "fmt"
9 "io"
· · ·
125// collected --depth commits. iter.ForEach surfaces whatever the callback
126// returns, so we can compare it back at the call site directly.
127var errStopIter = errors.New("history: stop iteration")
128
129// Bucketing divides [From, To] into N equal time slices. Used by the timeline
· · ·
201// (newest first → oldest first), and feeds every commit's first-parent diff
202// to the observer.
203func runHistory(repoPath string, observer CommitObserver) (HistoryWindow, error) {
204 repo, err := git.PlainOpenWithOptions(repoPath, &git.PlainOpenOptions{DetectDotGit: true})
205 if err != nil {
· · ·
206 return HistoryWindow{}, fmt.Errorf("open git repository: %w", err)
207 }
208
· · ·
209 head, err := repo.Head()
210 if err != nil {
211 if errors.Is(err, plumbing.ErrReferenceNotFound) {
212 observer.Finalise(HistoryWindow{}, emptySnapshot())
213 return HistoryWindow{}, nil
+ 12 more matches in this file
processor/history_author_timeline.go GO 6 matches · showing 5 view file →
186// when --by-author --timeline is set. Opens the repo, walks the window with
187// the configured bucket count, and writes the chosen format.
188func runAuthorTimelineReport(repoPath string) error {
189 observer := newHistoryAuthorTimelineObserver(HistoryBuckets)
190 if _, err := runHistory(repoPath, observer); err != nil {
· · ·
206}
207
208func renderAuthorTimeline(o *historyAuthorTimelineObserver) (string, error) {
209 switch strings.ToLower(Format) {
210 case "", "tabular", "wide":
· · ·
215 return renderAuthorTimelineJSON(o)
216 default:
217 return "", fmt.Errorf("unsupported --format %q for --by-author --timeline (supported: tabular, csv, json)", Format)
218 }
219}
· · ·
322}
323
324func renderAuthorTimelineCSV(o *historyAuthorTimelineObserver) (string, error) {
325 var sb strings.Builder
326 sb.WriteString(formatWindowComment(o.window))
· · ·
344 }
345 w.Flush()
346 if err := w.Error(); err != nil {
347 return "", err
348 }
+ 1 more matches in this file
processor/history_author_timeline_test.go GO 28 matches · showing 5 view file →
108 for _, c := range cases {
109 if got := b.Index(c.t); got != c.want {
110 t.Errorf("Index(%s) = %d, want %d", c.t, got, c.want)
111 }
112 }
· · ·
117 b := NewBucketing(when, when, 8)
118 if got := b.Index(when); got != 0 {
119 t.Errorf("degenerate window: Index = %d, want 0", got)
120 }
121 if got := b.Index(when.Add(time.Hour)); got != 0 {
· · ·
122 t.Errorf("degenerate window: future Index = %d, want 0", got)
123 }
124}
· · ·
129 b := NewBucketing(from, to, 10)
130 if got := b.Start(0); !got.Equal(from) {
131 t.Errorf("Start(0) = %s, want %s", got, from)
132 }
133 if got := b.Start(5); !got.Equal(from.Add(5 * 24 * time.Hour)) {
· · ·
134 t.Errorf("Start(5) = %s, want %s", got, from.Add(5*24*time.Hour))
135 }
136}
+ 23 more matches in this file
processor/history_authors.go GO 6 matches · showing 5 view file →
272// walks history with baseline seeding, and writes the chosen format to
273// stdout or FileOutput.
274func runAuthorsReport(repoPath string) error {
275 observer := newHistoryAuthorsObserver()
276 if _, err := runHistory(repoPath, observer); err != nil {
· · ·
292}
293
294func renderAuthors(o *historyAuthorsObserver) (string, error) {
295 switch strings.ToLower(Format) {
296 case "", "tabular", "wide":
· · ·
301 return renderAuthorsJSON(o)
302 default:
303 return "", fmt.Errorf("unsupported --format %q for --by-author (supported: tabular, csv, json)", Format)
304 }
305}
· · ·
480}
481
482func renderAuthorsCSV(o *historyAuthorsObserver) (string, error) {
483 var sb strings.Builder
484 sb.WriteString(formatWindowComment(o.window))
· · ·
513 }
514 w.Flush()
515 if err := w.Error(); err != nil {
516 return "", err
517 }
+ 1 more matches in this file
processor/history_authors_test.go GO 27 matches · showing 5 view file →
109
110 if alice.Code != 3 {
111 t.Errorf("Alice Code = %d, want 3", alice.Code)
112 }
113 if bob.Code != 4 {
· · ·
114 t.Errorf("Bob Code = %d, want 4", bob.Code)
115 }
116}
· · ·
136 }
137 if sum < 99.99 || sum > 100.01 {
138 t.Errorf("OwnsPercent sum = %f, want ~100", sum)
139 }
140}
· · ·
171 }
172 if sentinel.Code == 0 {
173 t.Errorf("sentinel Code = 0, want surviving baseline lines")
174 }
175 if sentinel.OwnsPercent < 50 {
· · ·
176 t.Errorf("sentinel OwnsPercent = %f, want > 50 (only 1 line added in window)", sentinel.OwnsPercent)
177 }
178}
+ 22 more matches in this file
processor/history_blame_test.go GO 29 matches · showing 5 view file →
12 want := []authorID{7, 7, 7}
13 if !equalIDs(got, want) {
14 t.Errorf("new file blame = %v, want %v", got, want)
15 }
16}
· · ·
21 want := []authorID{1, 1, 9, 9}
22 if !equalIDs(got, want) {
23 t.Errorf("append blame = %v, want %v", got, want)
24 }
25}
· · ·
30 want := []authorID{1, 1}
31 if !equalIDs(got, want) {
32 t.Errorf("delete blame = %v, want %v", got, want)
33 }
34}
· · ·
43 want := []authorID{1, 1, 2, 2, 1, 1}
44 if !equalIDs(got, want) {
45 t.Errorf("replace blame = %v, want %v", got, want)
46 }
47}
· · ·
52 want := []authorID{0, 0, 0, 0}
53 if !equalIDs(got, want) {
54 t.Errorf("pad blame = %v, want %v", got, want)
55 }
56}
+ 24 more matches in this file
processor/history_cache_test.go GO 1 matches view file →
120 }
121 if hf.Language != "Go" {
122 t.Errorf("%s language = %q, want Go", name, hf.Language)
123 }
124 }
processor/history_hotspots.go GO 6 matches · showing 5 view file →
22// --hotspots is set. Opens the repo at repoPath, walks history, and writes
23// the chosen format to stdout or FileOutput.
24func runHotspotsReport(repoPath string) error {
25 observer := newHotspotsObserver()
26 if _, err := runHistory(repoPath, observer); err != nil {
· · ·
198
199// renderHotspots returns the formatted output for the chosen --format.
200func renderHotspots(o *hotspotsObserver) (string, error) {
201 switch strings.ToLower(Format) {
202 case "", "tabular", "wide":
· · ·
207 return renderHotspotsJSON(o)
208 default:
209 return "", fmt.Errorf("unsupported --format %q for --hotspots (supported: tabular, csv, json)", Format)
210 }
211}
· · ·
291}
292
293func renderHotspotsCSV(o *hotspotsObserver) (string, error) {
294 var sb strings.Builder
295 sb.WriteString(formatWindowComment(o.window))
· · ·
319 }
320 w.Flush()
321 if err := w.Error(); err != nil {
322 return "", err
323 }
+ 1 more matches in this file
processor/history_hotspots_test.go GO 5 matches view file →
117 for i, h := range wantHeader {
118 if rows[0][i] != h {
119 t.Errorf("header col %d = %q, want %q", i, rows[0][i], h)
120 }
121 }
· · ·
146 }
147 if doc.Report != "hotspots" {
148 t.Errorf("report = %q, want hotspots", doc.Report)
149 }
150 if doc.Window.Commits != 2 {
· · ·
151 t.Errorf("window.commits = %d, want 2", doc.Window.Commits)
152 }
153 if len(doc.Files) == 0 {
· · ·
162 obs := newHotspotsObserver()
163 if _, err := renderHotspots(obs); err == nil {
164 t.Fatal("expected error for --format xml")
165 }
166}
· · ·
171 code, comment := splitChurnByType(added, lines)
172 if code != 2 || comment != 1 {
173 t.Errorf("splitChurnByType = (%d,%d), want (2,1)", code, comment)
174 }
175}
processor/history_ignore.go GO 2 matches view file →
35// parses them, and produces a matcher. Respects the existing --no-ignore
36// (Ignore) and --no-scc-ignore (SccIgnore) flag globals.
37func buildHistoryIgnore(repo *git.Repository, head plumbing.Hash) (*historyIgnore, error) {
38 commit, err := repo.CommitObject(head)
39 if err != nil {
· · ·
46
47 var patterns []gitignore.Pattern
48 err = tree.Files().ForEach(func(f *object.File) error {
49 if f.Mode == filemode.Dir || f.Mode == filemode.Submodule || f.Mode == filemode.Symlink {
50 return nil
processor/history_ignore_test.go GO 4 matches view file →
23
24 if !h.Match("vendor/foo.go", false) {
25 t.Errorf("vendor/foo.go should match vendor/ pattern")
26 }
27 if h.Match("foo.go", false) {
· · ·
28 t.Errorf("foo.go should not match vendor/ pattern")
29 }
30}
· · ·
33 var h *historyIgnore
34 if h.Match("anything", false) {
35 t.Errorf("nil matcher should match nothing")
36 }
37}
· · ·
50 got := splitDomain(c.in)
51 if len(got) != c.want {
52 t.Errorf("splitDomain(%q) = %v, want length %d", c.in, got, c.want)
53 }
54 }
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.