element_type
stringclasses
2 values
project_name
stringclasses
2 values
uuid
stringlengths
36
36
name
stringlengths
3
29
imports
stringlengths
0
312
structs
stringclasses
7 values
interfaces
stringclasses
1 value
file_location
stringlengths
58
108
code
stringlengths
41
7.22k
global_vars
stringclasses
3 values
package
stringclasses
11 values
tags
stringclasses
1 value
function
flightctl/test
494a4385-31ad-4914-bb79-86d0c775aa44
WithAttrs
['"log/slog"']
['IndentHandler', 'groupOrAttrs']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler.go
func (h *IndentHandler) WithAttrs(attrs []slog.Attr) slog.Handler { if len(attrs) == 0 { return h } return h.withGroupOrAttrs(groupOrAttrs{attrs: attrs}) }
indenthandler
function
flightctl/test
f7c7ebcb-0e08-4184-be17-260a8cb06f2e
withGroupOrAttrs
['IndentHandler', 'groupOrAttrs']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler.go
func (h *IndentHandler) withGroupOrAttrs(goa groupOrAttrs) *IndentHandler { h2 := *h h2.goas = make([]groupOrAttrs, len(h.goas)+1) copy(h2.goas, h.goas) h2.goas[len(h2.goas)-1] = goa return &h2 }
indenthandler
function
flightctl/test
49fedc14-9cd8-47cf-b00b-e68b8c43e499
Handle
['"context"', '"fmt"', '"log/slog"', '"runtime"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler.go
func (h *IndentHandler) Handle(ctx context.Context, r slog.Record) error { buf := make([]byte, 0, 1024) if !r.Time.IsZero() { buf = h.appendAttr(buf, slog.Time(slog.TimeKey, r.Time), 0) } buf = h.appendAttr(buf, slog.Any(slog.LevelKey, r.Level), 0) if r.PC != 0 { fs := runtime.CallersFrames([]uintptr{r.PC}) ...
indenthandler
function
flightctl/test
b7af3ddd-b2de-4e27-a5ce-d40d18c83e8c
appendAttr
['"fmt"', '"log/slog"', '"time"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler.go
func (h *IndentHandler) appendAttr(buf []byte, a slog.Attr, indentLevel int) []byte { // Resolve the Attr's value before doing anything else. a.Value = a.Value.Resolve() // Ignore empty Attrs. if a.Equal(slog.Attr{}) { return buf } // Indent 4 spaces per level. buf = fmt.Appendf(buf, "%*s", indentLevel*4, "") ...
indenthandler
file
flightctl/test
67b78552-62c3-4562-829e-5d37e6eecf9c
indent_handler_test.go
import ( "bufio" "bytes" "fmt" "reflect" "regexp" "strconv" "strings" "testing" "unicode" "log/slog" "testing/slogtest" )
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler_test.go
//go:build go1.21 package indenthandler import ( "bufio" "bytes" "fmt" "reflect" "regexp" "strconv" "strings" "testing" "unicode" "log/slog" "testing/slogtest" ) func TestSlogtest(t *testing.T) { var buf bytes.Buffer err := slogtest.TestHandler(New(&buf, nil), func() []map[string]any { return parseLo...
package indenthandler
function
flightctl/test
4c7252e8-d995-4e37-9d02-e8e966fb5ebf
TestSlogtest
['"bytes"', '"testing"', '"testing/slogtest"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler_test.go
func TestSlogtest(t *testing.T) { var buf bytes.Buffer err := slogtest.TestHandler(New(&buf, nil), func() []map[string]any { return parseLogEntries(buf.String()) }) if err != nil { t.Error(err) } }
indenthandler
function
flightctl/test
115f25f5-733c-4925-aa7b-93860e2177fc
Test
['"bytes"', '"regexp"', '"testing"', '"log/slog"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler_test.go
func Test(t *testing.T) { var buf bytes.Buffer l := slog.New(New(&buf, nil)) l.Info("hello", "a", 1, "b", true, "c", 3.14, slog.Group("g", "h", 1, "i", 2), "d", "NO") got := buf.String() wantre := `time: [-0-9T:.]+Z? level: INFO source: ".*/indent_handler_test.go:\d+" msg: "hello" a: 1 b: true c: 3.14 g: h: 1 ...
indenthandler
function
flightctl/test
f8cb55d6-a766-4e3f-b063-46bab5c0092b
parseLogEntries
['"bufio"', '"strings"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler_test.go
func parseLogEntries(s string) []map[string]any { var ms []map[string]any scan := bufio.NewScanner(strings.NewReader(s)) for scan.Scan() { m := parseGroup(scan) ms = append(ms, m) } if scan.Err() != nil { panic(scan.Err()) } return ms }
indenthandler
function
flightctl/test
df4a2a80-df8c-4b16-999b-2d8e37ded9be
parseGroup
['"bufio"', '"fmt"', '"strconv"', '"strings"', '"unicode"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler_test.go
func parseGroup(scan *bufio.Scanner) map[string]any { m := map[string]any{} groupIndent := -1 for { line := scan.Text() if line == "---" { // end of entry break } k, v, found := strings.Cut(line, ":") if !found { panic(fmt.Sprintf("no ':' in line %q", line)) } indent := strings.IndexFunc(k, func(...
indenthandler
function
flightctl/test
d4180e8e-3486-4543-b6a5-5e3ef55d3e08
TestParseLogEntries
['"reflect"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler2/indent_handler_test.go
func TestParseLogEntries(t *testing.T) { in := ` a: 1 b: 2 c: 3 g: h: 4 i: 5 d: 6 --- e: 7 --- ` want := []map[string]any{ { "a": "1", "b": "2", "c": "3", "g": map[string]any{ "h": "4", "i": "5", }, "d": "6", }, { "e": "7", }, } got := parseLogEntries(in[1:]) if !reflec...
indenthandler
file
flightctl/test
6f509e38-39b8-4aa7-99d7-f7f8d66e7787
indent_handler.go
import ( "context" "fmt" "io" "log/slog" "runtime" "slices" "sync" "time" )
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
//go:build go1.21 package indenthandler import ( "context" "fmt" "io" "log/slog" "runtime" "slices" "sync" "time" ) // !+IndentHandler type IndentHandler struct { opts Options preformatted []byte // data from WithGroup and WithAttrs unopenedGroups []string // groups from WithGroup that haven...
package indenthandler
function
flightctl/test
24224776-8b2b-4009-9749-0ebfdc439b5e
New
['"io"', '"log/slog"', '"sync"']
['IndentHandler', 'Options']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func New(out io.Writer, opts *Options) *IndentHandler { h := &IndentHandler{out: out, mu: &sync.Mutex{}} if opts != nil { h.opts = *opts } if h.opts.Level == nil { h.opts.Level = slog.LevelInfo } return h }
indenthandler
function
flightctl/test
dffaaf6d-53bc-42b5-b5e0-5c746ff8819c
Enabled
['"context"', '"log/slog"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func (h *IndentHandler) Enabled(ctx context.Context, level slog.Level) bool { return level >= h.opts.Level.Level() }
indenthandler
function
flightctl/test
94c4c211-18f9-48ba-afd3-78af2cd0b468
WithGroup
['"log/slog"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func (h *IndentHandler) WithGroup(name string) slog.Handler { if name == "" { return h } h2 := *h // Add an unopened group to h2 without modifying h. h2.unopenedGroups = make([]string, len(h.unopenedGroups)+1) copy(h2.unopenedGroups, h.unopenedGroups) h2.unopenedGroups[len(h2.unopenedGroups)-1] = name return ...
indenthandler
function
flightctl/test
07e4527c-8269-40b7-9a36-8ecb297df7a2
WithAttrs
['"log/slog"', '"slices"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func (h *IndentHandler) WithAttrs(attrs []slog.Attr) slog.Handler { if len(attrs) == 0 { return h } h2 := *h // Force an append to copy the underlying array. pre := slices.Clip(h.preformatted) // Add all groups from WithGroup that haven't already been added. h2.preformatted = h2.appendUnopenedGroups(pre, h2.in...
indenthandler
function
flightctl/test
15e780a3-46d0-497b-bb7e-abb07bd2158c
appendUnopenedGroups
['"fmt"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func (h *IndentHandler) appendUnopenedGroups(buf []byte, indentLevel int) []byte { for _, g := range h.unopenedGroups { buf = fmt.Appendf(buf, "%*s%s:\n", indentLevel*4, "", g) indentLevel++ } return buf }
indenthandler
function
flightctl/test
86ce2978-949a-4d93-855f-e257c600f84c
Handle
['"context"', '"fmt"', '"log/slog"', '"runtime"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func (h *IndentHandler) Handle(ctx context.Context, r slog.Record) error { buf := make([]byte, 0, 1024) if !r.Time.IsZero() { buf = h.appendAttr(buf, slog.Time(slog.TimeKey, r.Time), 0) } buf = h.appendAttr(buf, slog.Any(slog.LevelKey, r.Level), 0) if r.PC != 0 { fs := runtime.CallersFrames([]uintptr{r.PC}) ...
indenthandler
function
flightctl/test
5a552812-9423-41e2-9bb7-bb97b3d12a4c
appendAttr
['"fmt"', '"log/slog"', '"time"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler.go
func (h *IndentHandler) appendAttr(buf []byte, a slog.Attr, indentLevel int) []byte { // Resolve the Attr's value before doing anything else. a.Value = a.Value.Resolve() // Ignore empty Attrs. if a.Equal(slog.Attr{}) { return buf } // Indent 4 spaces per level. buf = fmt.Appendf(buf, "%*s", indentLevel*4, "") ...
indenthandler
file
flightctl/test
031d1fe3-1d6b-4b69-a68e-da3262937f21
indent_handler_test.go
import ( "bytes" "log/slog" "reflect" "regexp" "testing" "testing/slogtest" "gopkg.in/yaml.v3" )
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler_test.go
//go:build go1.21 package indenthandler import ( "bytes" "log/slog" "reflect" "regexp" "testing" "testing/slogtest" "gopkg.in/yaml.v3" ) // !+TestSlogtest func TestSlogtest(t *testing.T) { var buf bytes.Buffer err := slogtest.TestHandler(New(&buf, nil), func() []map[string]any { return parseLogEntries(t,...
package indenthandler
function
flightctl/test
f88b8c83-1810-4a42-b7e8-eb18426abcee
TestSlogtest
['"bytes"', '"testing"', '"testing/slogtest"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler_test.go
func TestSlogtest(t *testing.T) { var buf bytes.Buffer err := slogtest.TestHandler(New(&buf, nil), func() []map[string]any { return parseLogEntries(t, buf.Bytes()) }) if err != nil { t.Error(err) } }
indenthandler
function
flightctl/test
c03b603f-20d2-44df-83a7-f22676f14c52
Test
['"bytes"', '"log/slog"', '"regexp"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler_test.go
func Test(t *testing.T) { var buf bytes.Buffer l := slog.New(New(&buf, nil)) l.Info("hello", "a", 1, "b", true, "c", 3.14, slog.Group("g", "h", 1, "i", 2), "d", "NO") got := buf.String() wantre := `time: [-0-9T:.]+Z? level: INFO source: ".*/indent_handler_test.go:\d+" msg: "hello" a: 1 b: true c: 3.14 g: h: 1 ...
indenthandler
function
flightctl/test
8cf9961e-6c86-40ed-8ef1-31aec8cbc88c
parseLogEntries
['"bytes"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler_test.go
func parseLogEntries(t *testing.T, data []byte) []map[string]any { entries := bytes.Split(data, []byte("---\n")) entries = entries[:len(entries)-1] // last one is empty var ms []map[string]any for _, e := range entries { var m map[string]any if err := yaml.Unmarshal([]byte(e), &m); err != nil { t.Fatal(err) ...
indenthandler
function
flightctl/test
29c0897f-e17f-46ff-869a-d8d360956754
TestParseLogEntries
['"reflect"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler3/indent_handler_test.go
func TestParseLogEntries(t *testing.T) { in := ` a: 1 b: 2 c: 3 g: h: 4 i: five d: 6 --- e: 7 --- ` want := []map[string]any{ { "a": 1, "b": 2, "c": 3, "g": map[string]any{ "h": 4, "i": "five", }, "d": 6, }, { "e": 7, }, } got := parseLogEntries(t, []byte(in[1:])) if !r...
indenthandler
file
flightctl/test
6fc0c7c4-e4e8-4c20-90ee-ab9f67a4377a
indent_handler.go
import ( "context" "fmt" "io" "log/slog" "runtime" "slices" "strconv" "sync" "time" )
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
//go:build go1.21 package indenthandler import ( "context" "fmt" "io" "log/slog" "runtime" "slices" "strconv" "sync" "time" ) // !+IndentHandler type IndentHandler struct { opts Options preformatted []byte // data from WithGroup and WithAttrs unopenedGroups []string // groups from WithGroup...
package indenthandler
function
flightctl/test
2f9270ba-2d0a-4a2f-980f-e6c7fc2c6371
New
['"io"', '"log/slog"', '"sync"']
['IndentHandler', 'Options']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func New(out io.Writer, opts *Options) *IndentHandler { h := &IndentHandler{out: out, mu: &sync.Mutex{}} if opts != nil { h.opts = *opts } if h.opts.Level == nil { h.opts.Level = slog.LevelInfo } return h }
indenthandler
function
flightctl/test
7572ff64-3933-4f35-a8b7-49321a09226f
Enabled
['"context"', '"log/slog"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func (h *IndentHandler) Enabled(ctx context.Context, level slog.Level) bool { return level >= h.opts.Level.Level() }
indenthandler
function
flightctl/test
47f34e42-8a41-4338-9b22-4badb3395f18
WithGroup
['"log/slog"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func (h *IndentHandler) WithGroup(name string) slog.Handler { if name == "" { return h } h2 := *h // Add an unopened group to h2 without modifying h. h2.unopenedGroups = make([]string, len(h.unopenedGroups)+1) copy(h2.unopenedGroups, h.unopenedGroups) h2.unopenedGroups[len(h2.unopenedGroups)-1] = name return ...
indenthandler
function
flightctl/test
e4dda0b3-f1f0-489c-a70e-a9c61728e064
WithAttrs
['"log/slog"', '"slices"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func (h *IndentHandler) WithAttrs(attrs []slog.Attr) slog.Handler { if len(attrs) == 0 { return h } h2 := *h // Force an append to copy the underlying array. pre := slices.Clip(h.preformatted) // Add all groups from WithGroup that haven't already been added. h2.preformatted = h2.appendUnopenedGroups(pre, h2.in...
indenthandler
function
flightctl/test
a2a8326d-4000-4e4f-81a7-69486a35e311
appendUnopenedGroups
['"fmt"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func (h *IndentHandler) appendUnopenedGroups(buf []byte, indentLevel int) []byte { for _, g := range h.unopenedGroups { buf = fmt.Appendf(buf, "%*s%s:\n", indentLevel*4, "", g) indentLevel++ } return buf }
indenthandler
function
flightctl/test
71bfcca1-c11a-40b5-9d9a-1782643fd7bb
Handle
['"context"', '"log/slog"', '"runtime"', '"strconv"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func (h *IndentHandler) Handle(ctx context.Context, r slog.Record) error { bufp := allocBuf() buf := *bufp defer func() { *bufp = buf freeBuf(bufp) }() if !r.Time.IsZero() { buf = h.appendAttr(buf, slog.Time(slog.TimeKey, r.Time), 0) } buf = h.appendAttr(buf, slog.Any(slog.LevelKey, r.Level), 0) if r.PC !...
indenthandler
function
flightctl/test
529ce141-6770-4717-a299-4318eada3fe3
appendAttr
['"fmt"', '"log/slog"', '"strconv"', '"time"']
['IndentHandler']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func (h *IndentHandler) appendAttr(buf []byte, a slog.Attr, indentLevel int) []byte { // Resolve the Attr's value before doing anything else. a.Value = a.Value.Resolve() // Ignore empty Attrs. if a.Equal(slog.Attr{}) { return buf } // Indent 4 spaces per level. buf = fmt.Appendf(buf, "%*s", indentLevel*4, "") ...
indenthandler
function
flightctl/test
c65d5564-0038-4420-98e2-c060d2e22a88
allocBuf
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func allocBuf() *[]byte { return bufPool.Get().(*[]byte) }
indenthandler
function
flightctl/test
8bbee994-9664-43a2-a13c-5483b7f955a4
freeBuf
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler.go
func freeBuf(b *[]byte) { // To reduce peak allocation, return only smaller buffers to the pool. const maxBufferSize = 16 << 10 if cap(*b) <= maxBufferSize { *b = (*b)[:0] bufPool.Put(b) } }
indenthandler
file
flightctl/test
24308f3a-724f-4667-8abf-8a25fdef83ae
indent_handler_norace_test.go
import ( "fmt" "io" "log/slog" "strconv" "testing" )
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_norace_test.go
//go:build go1.21 && !race package indenthandler import ( "fmt" "io" "log/slog" "strconv" "testing" ) func TestAlloc(t *testing.T) { a := slog.String("key", "value") t.Run("Appendf", func(t *testing.T) { buf := make([]byte, 0, 100) g := testing.AllocsPerRun(2, func() { buf = fmt.Appendf(buf, "%s: %q\n"...
package indenthandler
function
flightctl/test
9f774cd9-963a-4a5d-9976-350955f79b99
TestAlloc
['"fmt"', '"io"', '"log/slog"', '"strconv"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_norace_test.go
func TestAlloc(t *testing.T) { a := slog.String("key", "value") t.Run("Appendf", func(t *testing.T) { buf := make([]byte, 0, 100) g := testing.AllocsPerRun(2, func() { buf = fmt.Appendf(buf, "%s: %q\n", a.Key, a.Value.String()) }) if g, w := int(g), 2; g != w { t.Errorf("got %d, want %d", g, w) } }) ...
indenthandler
file
flightctl/test
21acff8a-d8cb-4d14-90d0-27ffe11d1ed0
indent_handler_test.go
import ( "bytes" "log/slog" "reflect" "regexp" "testing" "testing/slogtest" "gopkg.in/yaml.v3" )
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_test.go
//go:build go1.21 package indenthandler import ( "bytes" "log/slog" "reflect" "regexp" "testing" "testing/slogtest" "gopkg.in/yaml.v3" ) // !+TestSlogtest func TestSlogtest(t *testing.T) { var buf bytes.Buffer err := slogtest.TestHandler(New(&buf, nil), func() []map[string]any { return parseLogEntries(t,...
package indenthandler
function
flightctl/test
1d11f5af-cbba-4a5a-b78d-7a9ed58cabf3
TestSlogtest
['"bytes"', '"testing"', '"testing/slogtest"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_test.go
func TestSlogtest(t *testing.T) { var buf bytes.Buffer err := slogtest.TestHandler(New(&buf, nil), func() []map[string]any { return parseLogEntries(t, buf.Bytes()) }) if err != nil { t.Error(err) } }
indenthandler
function
flightctl/test
47c618b9-81c5-44c8-ad4b-dd59c7d13d97
Test
['"bytes"', '"log/slog"', '"regexp"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_test.go
func Test(t *testing.T) { var buf bytes.Buffer l := slog.New(New(&buf, nil)) l.Info("hello", "a", 1, "b", true, "c", 3.14, slog.Group("g", "h", 1, "i", 2), "d", "NO") got := buf.String() wantre := `time: [-0-9T:.]+Z? level: INFO source: ".*/indent_handler_test.go:\d+" msg: "hello" a: 1 b: true c: 3.14 g: h: 1 ...
indenthandler
function
flightctl/test
2ae68f94-8c93-40d9-b8f8-04d1c48488aa
parseLogEntries
['"bytes"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_test.go
func parseLogEntries(t *testing.T, data []byte) []map[string]any { entries := bytes.Split(data, []byte("---\n")) entries = entries[:len(entries)-1] // last one is empty var ms []map[string]any for _, e := range entries { var m map[string]any if err := yaml.Unmarshal([]byte(e), &m); err != nil { t.Fatal(err) ...
indenthandler
function
flightctl/test
3eaebe58-82bf-425b-afaa-ff7c16655758
TestParseLogEntries
['"reflect"', '"testing"']
github.com/flightctl/test//tmp/repos/example/slog-handler-guide/indenthandler4/indent_handler_test.go
func TestParseLogEntries(t *testing.T) { in := ` a: 1 b: 2 c: 3 g: h: 4 i: five d: 6 --- e: 7 --- ` want := []map[string]any{ { "a": 1, "b": 2, "c": 3, "g": map[string]any{ "h": 4, "i": "five", }, "d": 6, }, { "e": 7, }, } got := parseLogEntries(t, []byte(in[1:])) if !r...
indenthandler
file
flightctl/test
e1c750f5-74bf-4e40-a822-f78770333573
main.go
import ( "html/template" "log" "net/http" "strings" )
github.com/flightctl/test//tmp/repos/example/template/main.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Template is a trivial web server that uses the text/template (and // html/template) package's "block" feature to implement a kind of template // inheritance....
package main
function
flightctl/test
014dc93a-f4d8-4693-b765-15f3bc99d205
main
['"log"', '"net/http"']
github.com/flightctl/test//tmp/repos/example/template/main.go
func main() { http.HandleFunc("/", indexHandler) http.HandleFunc("/image/", imageHandler) log.Fatal(http.ListenAndServe("localhost:8080", nil)) }
main
function
flightctl/test
3e7a8ee4-6dc0-4123-928a-007fe559b9f4
indexHandler
['"log"', '"net/http"']
['Index', 'Link', 'Image']
github.com/flightctl/test//tmp/repos/example/template/main.go
func indexHandler(w http.ResponseWriter, r *http.Request) { data := &Index{ Title: "Image gallery", Body: "Welcome to the image gallery.", } for name, img := range images { data.Links = append(data.Links, Link{ URL: "/image/" + name, Title: img.Title, }) } if err := indexTemplate.Execute(w, data);...
main
function
flightctl/test
e21b506a-3229-4db4-97ac-0610f374025c
imageHandler
['"log"', '"net/http"', '"strings"']
github.com/flightctl/test//tmp/repos/example/template/main.go
func imageHandler(w http.ResponseWriter, r *http.Request) { data, ok := images[strings.TrimPrefix(r.URL.Path, "/image/")] if !ok { http.NotFound(w, r) return } if err := imageTemplate.Execute(w, data); err != nil { log.Println(err) } }
main
file
final HF test
deccf4d6-b3f8-439d-98fe-cdc848b6d554
app.go
import ( "fmt" "net/http" )
github.com/final HF test//tmp/repos/example/appengine-hello/app.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package hello is a simple App Engine application that replies to requests // on /hello with a welcoming message. package hello import ( "fmt" "net/http" )...
package hello
function
final HF test
9ef1ff46-e52e-414c-9ce0-3d9fe9091c2e
init
['"net/http"']
github.com/final HF test//tmp/repos/example/appengine-hello/app.go
func init() { // Handle all requests with path /hello with the helloHandler function. http.HandleFunc("/hello", helloHandler) }
hello
function
final HF test
393f78d9-be3e-4df9-9953-62ba9ab33238
helloHandler
['"fmt"', '"net/http"']
github.com/final HF test//tmp/repos/example/appengine-hello/app.go
func helloHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Hello from the Go app") }
hello
file
final HF test
5b5dcecc-c913-4e3a-a987-61d4e3be723a
main.go
import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" )
github.com/final HF test//tmp/repos/example/gotypes/defsuses/main.go
package main import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" ) const hello = `package main import "fmt" func main() { fmt.Println("Hello, world") } ` // !+ func PrintDefsUses(fset *token.FileSet, files ...*ast.File) error { conf := types.Config{Importer: importer.Defau...
package main
function
final HF test
45de9330-d5d0-4ee0-a917-d0ef4b4b7cd5
PrintDefsUses
['"fmt"', '"go/ast"', '"go/importer"', '"go/token"', '"go/types"']
github.com/final HF test//tmp/repos/example/gotypes/defsuses/main.go
func PrintDefsUses(fset *token.FileSet, files ...*ast.File) error { conf := types.Config{Importer: importer.Default()} info := &types.Info{ Defs: make(map[*ast.Ident]types.Object), Uses: make(map[*ast.Ident]types.Object), } _, err := conf.Check("hello", fset, files, info) if err != nil { return err // type e...
main
function
final HF test
7e017b1d-9f04-422d-a54b-5ec28b77ae6d
main
['"go/parser"', '"go/token"', '"log"']
github.com/final HF test//tmp/repos/example/gotypes/defsuses/main.go
func main() { // Parse one file. fset := token.NewFileSet() f, err := parser.ParseFile(fset, "hello.go", hello, 0) if err != nil { log.Fatal(err) // parse error } if err := PrintDefsUses(fset, f); err != nil { log.Fatal(err) // type error } }
main
file
final HF test
5059c46a-967e-4abe-821d-fdd6d5bbe4a1
main.go
import ( "fmt" "go/ast" "log" "os" "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/go/packages" "golang.org/x/tools/go/types/typeutil" )
github.com/final HF test//tmp/repos/example/gotypes/doc/main.go
// The doc command prints the doc comment of a package-level object. package main import ( "fmt" "go/ast" "log" "os" "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/go/packages" "golang.org/x/tools/go/types/typeutil" ) func main() { if len(os.Args) != 3 { log.Fatal("Usage: doc <package> <object>") ...
package main
function
final HF test
e35070f0-ba1f-4001-8835-d98d50ea62a8
main
['"fmt"', '"go/ast"', '"log"', '"os"', '"golang.org/x/tools/go/ast/astutil"', '"golang.org/x/tools/go/packages"', '"golang.org/x/tools/go/types/typeutil"']
github.com/final HF test//tmp/repos/example/gotypes/doc/main.go
func main() { if len(os.Args) != 3 { log.Fatal("Usage: doc <package> <object>") } //!+part1 pkgpath, name := os.Args[1], os.Args[2] // Load complete type information for the specified packages, // along with type-annotated syntax. // Types for dependencies are loaded from export data. conf := &packages.Confi...
main
file
final HF test
0b48e7ba-b905-4a7e-91a6-3a39bc4fe8b8
gen.go
github.com/final HF test//tmp/repos/example/gotypes/gen.go
//go:generate bash -c "go run ../internal/cmd/weave/weave.go ./go-types.md > README.md" package gotypes
package gotypes
file
final HF test
c4dc89b2-3cef-4e4d-ade2-902f11c227c6
hello.go
import "fmt"
github.com/final HF test//tmp/repos/example/gotypes/hello/hello.go
// !+ package main import "fmt" func main() { fmt.Println("Hello, 世界") } //!-
package main
function
final HF test
c6f854e0-90ad-4a59-9e10-5a5933bcf866
main
github.com/final HF test//tmp/repos/example/gotypes/hello/hello.go
func main() { fmt.Println("Hello, 世界") }
main
file
final HF test
c892f0f2-1d6a-42a4-8b2d-42e4e8232a6f
main.go
import ( "flag" "fmt" "go/ast" "go/token" "go/types" "log" "os" "golang.org/x/tools/go/packages" )
github.com/final HF test//tmp/repos/example/gotypes/hugeparam/main.go
// The hugeparam command identifies by-value parameters that are larger than n bytes. // // Example: // // $ ./hugeparams encoding/xml package main import ( "flag" "fmt" "go/ast" "go/token" "go/types" "log" "os" "golang.org/x/tools/go/packages" ) // !+ var bytesFlag = flag.Int("bytes", 48, "maximum parameter...
package main
function
final HF test
b6629a37-ed78-4986-a67f-5d98487438b1
PrintHugeParams
['"fmt"', '"go/ast"', '"go/token"', '"go/types"']
github.com/final HF test//tmp/repos/example/gotypes/hugeparam/main.go
func PrintHugeParams(fset *token.FileSet, info *types.Info, sizes types.Sizes, files []*ast.File) { checkTuple := func(descr string, tuple *types.Tuple) { for i := 0; i < tuple.Len(); i++ { v := tuple.At(i) if sz := sizes.Sizeof(v.Type()); sz > int64(*bytesFlag) { fmt.Printf("%s: %q %s: %s = %d bytes\n", ...
{'bytesFlag': 'flag.Int("bytes", 48, "maximum parameter size in bytes")'}
main
function
final HF test
529fa1ed-22c4-4dac-b149-0cca792533d6
main
['"flag"', '"log"', '"os"', '"golang.org/x/tools/go/packages"']
github.com/final HF test//tmp/repos/example/gotypes/hugeparam/main.go
func main() { flag.Parse() // Load complete type information for the specified packages, // along with type-annotated syntax and the "sizeof" function. // Types for dependencies are loaded from export data. conf := &packages.Config{Mode: packages.LoadSyntax} pkgs, err := packages.Load(conf, flag.Args()...) if e...
main
file
final HF test
3b21758c-adf0-4836-a8b1-6f9830fc3c0e
main.go
import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" )
github.com/final HF test//tmp/repos/example/gotypes/implements/main.go
package main import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" ) // !+input const input = `package main type A struct{} func (*A) f() type B int func (B) f() func (*B) g() type I interface { f() } type J interface { g() } ` //!-input func main() { // Parse one file. fset := t...
package main
function
final HF test
f4e53958-f7ae-4f14-84c6-1760e059362d
main
['"fmt"', '"go/ast"', '"go/importer"', '"go/parser"', '"go/token"', '"go/types"', '"log"']
github.com/final HF test//tmp/repos/example/gotypes/implements/main.go
func main() { // Parse one file. fset := token.NewFileSet() f, err := parser.ParseFile(fset, "input.go", input, 0) if err != nil { log.Fatal(err) // parse error } conf := types.Config{Importer: importer.Default()} pkg, err := conf.Check("hello", fset, []*ast.File{f}, nil) if err != nil { log.Fatal(err) // t...
main
file
final HF test
8a639290-a518-48c7-846a-1fc2c2a12968
lookup.go
import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" "strings" )
github.com/final HF test//tmp/repos/example/gotypes/lookup/lookup.go
package main import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" "strings" ) // !+input const hello = ` package main import "fmt" // append func main() { // fmt fmt.Println("Hello, world") // main main, x := 1, 2 // main print(main, x...
package main
function
final HF test
7f5890b3-99ca-447e-a584-24539fc74ad5
main
['"fmt"', '"go/ast"', '"go/importer"', '"go/parser"', '"go/token"', '"go/types"', '"log"', '"strings"']
github.com/final HF test//tmp/repos/example/gotypes/lookup/lookup.go
func main() { fset := token.NewFileSet() f, err := parser.ParseFile(fset, "hello.go", hello, parser.ParseComments) if err != nil { log.Fatal(err) // parse error } conf := types.Config{Importer: importer.Default()} pkg, err := conf.Check("cmd/hello", fset, []*ast.File{f}, nil) if err != nil { log.Fatal(err) ...
main
file
final HF test
a554e3a0-67fd-4158-bb63-a8fe0d972902
main.go
import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" )
github.com/final HF test//tmp/repos/example/gotypes/nilfunc/main.go
package main import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" ) // !+input const input = `package main import "bytes" func main() { var buf bytes.Buffer if buf.Bytes == nil && bytes.Repeat != nil && main == nil { // ... } } ` //!-input var fset = token.NewFileSet() func m...
package main
function
final HF test
6cf10a67-f573-41ca-bf5c-21276946f843
main
['"go/ast"', '"go/importer"', '"go/parser"', '"go/types"', '"log"']
github.com/final HF test//tmp/repos/example/gotypes/nilfunc/main.go
func main() { f, err := parser.ParseFile(fset, "input.go", input, 0) if err != nil { log.Fatal(err) // parse error } conf := types.Config{Importer: importer.Default()} info := &types.Info{ Defs: make(map[*ast.Ident]types.Object), Uses: make(map[*ast.Ident]types.Object), Types: make(map[ast.Expr]types.Typ...
{'fset': 'token.NewFileSet()'}
main
function
final HF test
e4c7ba63-0cf6-4d1c-8573-4c6c77973122
CheckNilFuncComparison
['"fmt"', '"go/ast"', '"go/token"', '"go/types"']
github.com/final HF test//tmp/repos/example/gotypes/nilfunc/main.go
func CheckNilFuncComparison(info *types.Info, n ast.Node) { e, ok := n.(*ast.BinaryExpr) if !ok { return // not a binary operation } if e.Op != token.EQL && e.Op != token.NEQ { return // not a comparison } // If this is a comparison against nil, find the other operand. var other ast.Expr if info.Types[e.X]...
{'fset': 'token.NewFileSet()'}
main
file
final HF test
ba70b7c0-b3f2-43e0-837c-87de4ecc8929
main.go
import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" )
github.com/final HF test//tmp/repos/example/gotypes/pkginfo/main.go
// !+ package main import ( "fmt" "go/ast" "go/importer" "go/parser" "go/token" "go/types" "log" ) const hello = `package main import "fmt" func main() { fmt.Println("Hello, world") }` func main() { fset := token.NewFileSet() // Parse the input string, []byte, or io.Reader, // recording position...
package main
function
final HF test
d959cd20-1a2e-4584-9af5-a180d7aa72f8
main
['"fmt"', '"go/ast"', '"go/importer"', '"go/parser"', '"go/token"', '"go/types"', '"log"']
github.com/final HF test//tmp/repos/example/gotypes/pkginfo/main.go
func main() { fset := token.NewFileSet() // Parse the input string, []byte, or io.Reader, // recording position information in fset. // ParseFile returns an *ast.File, a syntax tree. f, err := parser.ParseFile(fset, "hello.go", hello, 0) if err != nil { log.Fatal(err) // parse error } // A Config controls v...
main
file
final HF test
865287ad-3893-44f7-8b6b-6f36b6a4e37c
main.go
import ( "fmt" "go/types" "log" "os" "strings" "unicode" "unicode/utf8" "golang.org/x/tools/go/packages" )
github.com/final HF test//tmp/repos/example/gotypes/skeleton/main.go
// The skeleton command prints the boilerplate for a concrete type // that implements the specified interface type. // // Example: // // $ ./skeleton io ReadWriteCloser buffer // // *buffer implements io.ReadWriteCloser. // type buffer struct{ /* ... */ } // func (b *buffer) Close() error { panic("unimplemented") } // ...
package main
function
final HF test
ab93b50d-ac2e-412f-88f0-d4ec45469dbc
PrintSkeleton
['"fmt"', '"go/types"', '"strings"', '"unicode/utf8"']
github.com/final HF test//tmp/repos/example/gotypes/skeleton/main.go
func PrintSkeleton(pkg *types.Package, ifacename, concname string) error { obj := pkg.Scope().Lookup(ifacename) if obj == nil { return fmt.Errorf("%s.%s not found", pkg.Path(), ifacename) } if _, ok := obj.(*types.TypeName); !ok { return fmt.Errorf("%v is not a named type", obj) } iface, ok := obj.Type().Unde...
main
function
final HF test
a8c42c04-a259-4b6b-b1b7-9a077c19ec0b
isValidIdentifier
['"unicode"']
github.com/final HF test//tmp/repos/example/gotypes/skeleton/main.go
func isValidIdentifier(id string) bool { for i, r := range id { if !unicode.IsLetter(r) && !(i > 0 && unicode.IsDigit(r)) { return false } } return id != "" }
main
function
final HF test
2990b7c1-e804-4c5d-ae12-494765484409
main
['"log"', '"os"', '"golang.org/x/tools/go/packages"']
github.com/final HF test//tmp/repos/example/gotypes/skeleton/main.go
func main() { if len(os.Args) != 4 { log.Fatal(usage) } pkgpath, ifacename, concname := os.Args[1], os.Args[2], os.Args[3] // Load only exported type information for the specified package. conf := &packages.Config{Mode: packages.NeedTypes} pkgs, err := packages.Load(conf, pkgpath) if err != nil { log.Fatal(...
main
file
final HF test
033a4304-1762-4780-a34c-6e301c172b08
main.go
import ( "bytes" "fmt" "go/ast" "go/format" "go/importer" "go/parser" "go/token" "go/types" "log" )
github.com/final HF test//tmp/repos/example/gotypes/typeandvalue/main.go
package main import ( "bytes" "fmt" "go/ast" "go/format" "go/importer" "go/parser" "go/token" "go/types" "log" ) // !+input const input = ` package main var m = make(map[string]int) func main() { v, ok := m["hello, " + "world"] print(rune(v), ok) } ` //!-input var fset = token.NewFileSet() func main()...
package main
function
final HF test
6d9c1cbb-d6b0-4621-a910-a81839977654
main
['"fmt"', '"go/ast"', '"go/importer"', '"go/parser"', '"go/types"', '"log"']
github.com/final HF test//tmp/repos/example/gotypes/typeandvalue/main.go
func main() { f, err := parser.ParseFile(fset, "hello.go", input, 0) if err != nil { log.Fatal(err) // parse error } conf := types.Config{Importer: importer.Default()} info := &types.Info{Types: make(map[ast.Expr]types.TypeAndValue)} if _, err := conf.Check("cmd/hello", fset, []*ast.File{f}, info); err != nil ...
{'fset': 'token.NewFileSet()'}
main
function
final HF test
b3c34be5-bf42-4957-8851-159e9743fb56
nodeString
['"bytes"', '"go/ast"', '"go/format"']
github.com/final HF test//tmp/repos/example/gotypes/typeandvalue/main.go
func nodeString(n ast.Node) string { var buf bytes.Buffer format.Node(&buf, fset, n) return buf.String() }
{'fset': 'token.NewFileSet()'}
main
function
final HF test
ca1e8308-90fe-4c77-a4fb-bec4d933ab7c
mode
['"go/types"']
github.com/final HF test//tmp/repos/example/gotypes/typeandvalue/main.go
func mode(tv types.TypeAndValue) string { s := "" if tv.IsVoid() { s += ",void" } if tv.IsType() { s += ",type" } if tv.IsBuiltin() { s += ",builtin" } if tv.IsValue() { s += ",value" } if tv.IsNil() { s += ",nil" } if tv.Addressable() { s += ",addressable" } if tv.Assignable() { s += ",assi...
main
file
final HF test
6f17709a-ce13-41fc-998c-101620f37ee0
hello.go
import ( "flag" "fmt" "log" "os" "golang.org/x/example/hello/reverse" )
github.com/final HF test//tmp/repos/example/hello/hello.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Hello is a hello, world program, demonstrating // how to write a simple command-line program. // // Usage: // // hello [options] [name] // // The options are...
package main
function
final HF test
7bb63290-3d80-4006-908f-16518d4b75e8
usage
['"flag"', '"fmt"', '"os"']
github.com/final HF test//tmp/repos/example/hello/hello.go
func usage() { fmt.Fprintf(os.Stderr, "usage: hello [options] [name]\n") flag.PrintDefaults() os.Exit(2) }
main
function
final HF test
3d6ec9d5-1f42-4ef7-be70-be55ee32af3a
main
['"flag"', '"fmt"', '"log"', '"golang.org/x/example/hello/reverse"']
github.com/final HF test//tmp/repos/example/hello/hello.go
func main() { // Configure logging for a command-line program. log.SetFlags(0) log.SetPrefix("hello: ") // Parse flags. flag.Usage = usage flag.Parse() // Parse and validate arguments. name := "world" args := flag.Args() if len(args) >= 2 { usage() } if len(args) >= 1 { name = args[0] } if name == "...
main
file
final HF test
f7c724f4-4257-4ded-937b-ac9752110d5c
example_test.go
import ( "fmt" "golang.org/x/example/hello/reverse" )
github.com/final HF test//tmp/repos/example/hello/reverse/example_test.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package reverse_test import ( "fmt" "golang.org/x/example/hello/reverse" ) func ExampleString() { fmt.Println(reverse.String("hello")) // Output: olleh }...
package reverse_test
function
final HF test
d1d47813-0a33-4b4f-8861-b01b8386bd8f
ExampleString
['"fmt"', '"golang.org/x/example/hello/reverse"']
github.com/final HF test//tmp/repos/example/hello/reverse/example_test.go
func ExampleString() { fmt.Println(reverse.String("hello")) // Output: olleh }
reverse_test
file
final HF test
a81889e1-f777-478b-8c48-95dd98d9fabf
reverse.go
github.com/final HF test//tmp/repos/example/hello/reverse/reverse.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package reverse can reverse things, particularly strings. package reverse // String returns its argument string reversed rune-wise left to right. func Strin...
package reverse
function
final HF test
335a1f50-8b28-4687-975f-d1586958131e
String
github.com/final HF test//tmp/repos/example/hello/reverse/reverse.go
func String(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { r[i], r[j] = r[j], r[i] } return string(r) }
reverse
file
final HF test
494292d9-47a9-4401-a54a-c71e0c29be0f
reverse_test.go
import "testing"
github.com/final HF test//tmp/repos/example/hello/reverse/reverse_test.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package reverse import "testing" func TestString(t *testing.T) { for _, c := range []struct { in, want string }{ {"Hello, world", "dlrow ,olleH"}, {"H...
package reverse
function
final HF test
482a5231-4066-4dff-b360-c52e3b0a36d1
TestString
github.com/final HF test//tmp/repos/example/hello/reverse/reverse_test.go
func TestString(t *testing.T) { for _, c := range []struct { in, want string }{ {"Hello, world", "dlrow ,olleH"}, {"Hello, 世界", "界世 ,olleH"}, {"", ""}, } { got := String(c.in) if got != c.want { t.Errorf("String(%q) == %q, want %q", c.in, got, c.want) } } }
reverse
file
final HF test
6c41d0c3-b7c3-4958-8bc7-16df6b3f0a1d
server.go
import ( "flag" "fmt" "html" "log" "net/http" "os" "runtime/debug" "strings" )
github.com/final HF test//tmp/repos/example/helloserver/server.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Hello is a simple hello, world demonstration web server. // // It serves version information on /version and answers // any other request like /name by sayin...
package main
function
final HF test
ef3b17e3-8926-41c6-8c23-5f83c7db6aef
usage
['"flag"', '"fmt"', '"os"']
github.com/final HF test//tmp/repos/example/helloserver/server.go
func usage() { fmt.Fprintf(os.Stderr, "usage: helloserver [options]\n") flag.PrintDefaults() os.Exit(2) }
main
function
final HF test
35a3ba7d-693a-4907-a918-ef2709ec11ad
main
['"flag"', '"log"', '"net/http"']
github.com/final HF test//tmp/repos/example/helloserver/server.go
func main() { // Parse flags. flag.Usage = usage flag.Parse() // Parse and validate arguments (none). args := flag.Args() if len(args) != 0 { usage() } // Register handlers. // All requests not otherwise mapped with go to greet. // /version is mapped specifically to version. http.HandleFunc("/", greet) ...
main
function
final HF test
5f18e1fb-d88a-4d2f-b22f-f87d486054f2
version
['"fmt"', '"html"', '"net/http"', '"runtime/debug"']
github.com/final HF test//tmp/repos/example/helloserver/server.go
func version(w http.ResponseWriter, r *http.Request) { info, ok := debug.ReadBuildInfo() if !ok { http.Error(w, "no build information available", 500) return } fmt.Fprintf(w, "<!DOCTYPE html>\n<pre>\n") fmt.Fprintf(w, "%s\n", html.EscapeString(info.String())) }
main
function
final HF test
95f289e2-1fe4-4677-8c26-efb3bb096a2d
greet
['"fmt"', '"html"', '"net/http"', '"strings"']
github.com/final HF test//tmp/repos/example/helloserver/server.go
func greet(w http.ResponseWriter, r *http.Request) { name := strings.Trim(r.URL.Path, "/") if name == "" { name = "Gopher" } fmt.Fprintf(w, "<!DOCTYPE html>\n") fmt.Fprintf(w, "%s, %s!\n", *greeting, html.EscapeString(name)) }
main
file
final HF test
e0eae9d8-8231-455c-bc03-ec333e5d982e
weave.go
import ( "bufio" "bytes" "fmt" "log" "os" "path/filepath" "regexp" "strings" )
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
// The weave command is a simple preprocessor for markdown files. // It builds a table of contents and processes %include directives. // // Example usage: // // $ go run internal/cmd/weave go-types.md > README.md // // The weave command copies lines of the input file to standard output, with two // exceptions: // // If...
package main
function
final HF test
b674e6ce-1331-422d-9507-3cfec1dfcdf6
main
['"bufio"', '"fmt"', '"log"', '"os"', '"path/filepath"', '"strings"']
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
func main() { log.SetFlags(0) log.SetPrefix("weave: ") if len(os.Args) != 2 { log.Fatal("usage: weave input.md\n") } f, err := os.Open(os.Args[1]) if err != nil { log.Fatal(err) } defer f.Close() wd, err := os.Getwd() if err != nil { log.Fatal(err) } curDir := filepath.Base(wd) fmt.Println("<!-- A...
main
function
final HF test
84424c55-9a1c-4fcc-bd45-57943dbf1501
include
['"bufio"', '"bytes"', '"fmt"', '"os"', '"regexp"']
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
func include(file, tag string) (string, error) { f, err := os.Open(file) if err != nil { return "", err } defer f.Close() startre, err := regexp.Compile("!\\+" + tag + "$") if err != nil { return "", err } endre, err := regexp.Compile("!\\-" + tag + "$") if err != nil { return "", err } var text byte...
main
function
final HF test
d4d178f8-0391-4180-a4cc-1019508475ff
isBlank
['"strings"']
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
func isBlank(line string) bool { return strings.TrimSpace(line) == "" }
main
function
final HF test
b650ad36-8b71-40ef-a6e4-281b3257d827
indented
['"strings"']
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
func indented(line string) bool { return strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") }
main
function
final HF test
032a4361-99be-48a7-8ae1-0e1152cdee00
cleanListing
['"strings"']
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
func cleanListing(text string) string { lines := strings.Split(text, "\n") // remove minimum number of leading tabs from all non-blank lines tabs := 999 for i, line := range lines { if strings.TrimSpace(line) == "" { lines[i] = "" } else { if n := leadingTabs(line); n < tabs { tabs = n } } } f...
main
function
final HF test
2113f572-fa4b-4434-a0f4-94bc9ef3bc5a
leadingTabs
github.com/final HF test//tmp/repos/example/internal/cmd/weave/weave.go
func leadingTabs(s string) int { var i int for i = 0; i < len(s); i++ { if s[i] != '\t' { break } } return i }
main
file
final HF test
4cd839a9-fda2-4632-974c-d485f31cf8f3
main.go
import ( "expvar" "flag" "fmt" "html/template" "log" "net/http" "sync" "time" )
github.com/final HF test//tmp/repos/example/outyet/main.go
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Outyet is a web server that announces whether or not a particular Go version // has been tagged. package main import ( "expvar" "flag" "fmt" "html/templ...
package main
function
final HF test
cfff8da5-6393-4955-b8b8-6e93f1f0c7c3
main
['"flag"', '"fmt"', '"log"', '"net/http"']
github.com/final HF test//tmp/repos/example/outyet/main.go
func main() { flag.Parse() changeURL := fmt.Sprintf("%sgo%s", baseChangeURL, *version) http.Handle("/", NewServer(*version, changeURL, *pollPeriod)) log.Printf("serving http://%s", *httpAddr) log.Fatal(http.ListenAndServe(*httpAddr, nil)) }
main
function
final HF test
44b471bb-30ee-4f77-b65c-df36eaa1e8ff
NewServer
['"time"']
['Server']
github.com/final HF test//tmp/repos/example/outyet/main.go
func NewServer(version, url string, period time.Duration) *Server { s := &Server{version: version, url: url, period: period} go s.poll() return s }
main
function
final HF test
30b17d1b-6fbc-461e-b8c7-8051358ab5b4
poll
['Server']
github.com/final HF test//tmp/repos/example/outyet/main.go
func (s *Server) poll() { for !isTagged(s.url) { pollSleep(s.period) } s.mu.Lock() s.yes = true s.mu.Unlock() pollDone() }
main