Skip to content

Commit 028e42a

Browse files
committed
writer: more verbose variable naming to have better docs
1 parent 14f33f3 commit 028e42a

11 files changed

Lines changed: 334 additions & 205 deletions

File tree

cmd/gtrace/main.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,14 @@ func buildFunc(info types.Info, fn *ast.FuncType) (ret Func, err error) {
327327
if t == nil {
328328
log.Fatalf("unknown type: %s", p.Type)
329329
}
330-
ret.Params = append(ret.Params, t)
330+
var name string
331+
if len(p.Names) > 0 {
332+
name = p.Names[0].Name
333+
}
334+
ret.Params = append(ret.Params, Param{
335+
Name: name,
336+
Type: t,
337+
})
331338
}
332339
if fn.Results == nil {
333340
return ret, nil
@@ -404,8 +411,13 @@ type Hook struct {
404411
Func Func
405412
}
406413

414+
type Param struct {
415+
Name string // Might be empty.
416+
Type types.Type
417+
}
418+
407419
type Func struct {
408-
Params []types.Type
420+
Params []Param
409421
Result []Func // 0 or 1.
410422
}
411423

@@ -473,6 +485,14 @@ func split(s string, c byte) (s1, s2 string) {
473485
return s[:i], s[i+1:]
474486
}
475487

488+
func rsplit(s string, c byte) (s1, s2 string) {
489+
i := strings.LastIndexByte(s, c)
490+
if i == -1 {
491+
return s, ""
492+
}
493+
return s[:i], s[i+1:]
494+
}
495+
476496
func scanBuildConstraints(r io.Reader) (cs []string, err error) {
477497
br := bufio.NewReader(r)
478498
for {

0 commit comments

Comments
 (0)