Skip to content
Permalink
Browse files

Don't add whitespace to //extern comments

When using gccgo, the //extern comment can be used to declare C
functions to call from Go, see
https://golang.org/doc/install/gccgo#Function_names

These comments shouldn't have a whitespace added.
  • Loading branch information...
tklauser authored and mvdan committed May 13, 2019
1 parent c5b444f commit c76ff6ff55bf13e95469bef749eb27662057c622
Showing with 8 additions and 1 deletion.
  1. +2 −1 internal/gofumpt.go
  2. +6 −0 testdata/scripts/comment-spaced.txt
@@ -174,8 +174,9 @@ func (f *fumpter) printLength(node ast.Node) int {
// //someword: | similar to the syntax above, like lint:ignore
// //line | inserted line information for cmd/compile
// //export | to mark cgo funcs for exporting
// //extern | C function declarations for gccgo
// //sys(nb)? | syscall function wrapper prototypes
var rxCommentDirective = regexp.MustCompile(`^([a-z]+:|line\b|export\b|sys(nb)?\b)`)
var rxCommentDirective = regexp.MustCompile(`^([a-z]+:|line\b|export\b|extern\b|sys(nb)?\b)`)

// visit takes either an ast.Node or a []ast.Stmt.
func (f *fumpter) applyPre(c *astutil.Cursor) {
@@ -18,6 +18,9 @@ package p

//export CgoFunc

//extern open
func c_open(name *byte, mode int, perm int) int

//line 123

//sys Unlink(path string) (err error)
@@ -56,6 +59,9 @@ package p

//export CgoFunc

//extern open
func c_open(name *byte, mode int, perm int) int

//line 123

//sys Unlink(path string) (err error)

0 comments on commit c76ff6f

Please sign in to comment.
You can’t perform that action at this time.