func setTest(line *modfile.Line, add bool) {
	if isTest(line) == add {
		return
	}
	if add {
		if len(line.Suffix) == 0 {
			line.Suffix = []modfile.Comment{{Token: testComment, Suffix: true}}
			return
		}
		com := &line.Suffix[0]
		text := strings.TrimSpace(strings.TrimPrefix(com.Token, string(slashSlash)))
		if text == "" {
			com.Token = testComment
			return
		}
		com.Token = "// test; " + text
	} else {
		f := strings.TrimSpace(strings.TrimPrefix(line.Suffix[0].Token, string(slashSlash)))
		if f == "test" {
			line.Suffix = nil
			return
		}
		com := &line.Suffix[0]
		i := strings.Index(com.Token, "test;")
		com.Token = "//" + com.Token[i+len("test;"):]
	}
}
setTest sets line to have(or not have) a "// test" comment.
package main
import (
	"strings"
	"golang.org/x/mod/modfile"
)
var (
	slashSlash  = []byte("//")
	testComment = "// test"
)
func isTest(line *modfile.Line) bool {
	if len(line.Suffix) == 0 {
		return false
	}
	f := strings.Fields(strings.TrimPrefix(line.Suffix[0].Token, string(slashSlash)))
	return (len(f) == 1 && f[0] == "test" || len(f) > 1 && f[0] == "test;")
}