79264107

Date: 2024-12-09 07:11:49
Score: 0.5
Natty:
Report link

You can refer the golang scanner and copy the code here. In short, you need to create a scanner and scan the source file by yourself.


    reader := bytes.NewBuffer(src)
    scanner := bufio.NewScanner(reader)
    for scanner.Scan() {
        line := scanner.Text()
        nline := line
        l += len(line)
        // copied from src/cmd/compile/internal/syntax/parser.go
        text := commentText(line)
        // see src/cmd/compile/internal/noder/noder.go#L220
        // to handle the gc directive you like.
        if strings.HasPrefix(text, "go:linkname ") {
                // do y
        }

    }

https://github.com/golang/go/blob/c8fb6ae617d65b42089202040d8fbd309d1a0fe4/src/cmd/compile/internal/noder/noder.go#L220

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Xie Yuchen