File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ func (tv *tokenVisitor) comment(c *ast.Comment, importByName map[string]*types.P
164164 if strings .HasPrefix (c .Text , "//go:" ) {
165165 tv .godirective (c )
166166 return
167+ } else if strings .HasPrefix (c .Text , "//export" ) {
168+ tv .goexport (c )
169+ return
167170 }
168171
169172 pkgScope := tv .pkg .Types ().Scope ()
@@ -923,6 +926,21 @@ func (tv *tokenVisitor) godirective(c *ast.Comment) {
923926 }
924927}
925928
929+ func (tv * tokenVisitor ) goexport (c * ast.Comment ) {
930+ funcName := strings .TrimPrefix (c .Text , "//export " )
931+
932+ // Make the 'export func' part stand out, the rest is comments.
933+ tv .token (c .Pos (), len ("//" ), semtok .TokComment )
934+
935+ exportStart := c .Pos () + token .Pos (len ("//" ))
936+ tv .token (exportStart , len ("export " ), semtok .TokNamespace )
937+
938+ if len (funcName ) > 0 {
939+ funcStart := c .Pos () + token .Pos (len ("//export " ))
940+ tv .token (funcStart , len (funcName ), semtok .TokFunction )
941+ }
942+ }
943+
926944// Go 1.20 strings.CutPrefix.
927945func stringsCutPrefix (s , prefix string ) (after string , found bool ) {
928946 if ! strings .HasPrefix (s , prefix ) {
You can’t perform that action at this time.
0 commit comments