// check checks the provided text and outputs information about any misspellings
// in the text.
check checks the provided text and outputs information about any misspellings
in the text.
// check checks the provided text and outputs information about any misspellings // in the text .
func (c *checker) check(text string, pos token.Pos, where string) {
	sc := bufio.NewScanner(strings.NewReader(text))
	w := words{}
	sc.Split(w.ScanWords)
	var (
		args    []interface{}
		lastPos int
	)
	seen := make(map[string]bool)
	for sc.Scan() {
		word := sc.Text()
		switch {
		case strings.HasSuffix(word, "'s"):
			word = strings.TrimSuffix(word, "'s")
		case strings.HasSuffix(word, "'d"):
			word = strings.TrimSuffix(word, "'d")
		case strings.HasSuffix(word, "'th"):
			word = strings.TrimSuffix(word, "'th")
		}
		if (c.ignoreUpper && allUpper(word)) || c.spelling.IsCorrect(word) {
			continue
		}
		if !seen[word] {
			fmt.Printf("%v: %q is misspelled in %s\n", c.fileset.Position(pos), word, where)
			seen[word] = true
		}
		if c.show {
			if w.current.pos != lastPos {
				args = append(args, text[lastPos:w.current.pos])
			}
			args = append(args, c.warn(text[w.current.pos:w.current.pos+len(word)]), text[w.current.pos+len(word):w.current.end])
			lastPos = w.current.end
		}
	}
	if args != nil {
		if lastPos != len(text) {
			args = append(args, text[lastPos:])
		}
		lines := strings.Split(join(args), "\n")
		if lines[len(lines)-1] == "" {
			lines = lines[:len(lines)-1]
		}
		fmt.Printf("\t%s\n", strings.Join(lines, "\n\t"))
	}
}
func ( c * checker ) check ( text string , pos token . Pos , where string ) { sc := bufio . NewScanner ( strings . NewReader ( text ) ) w := words { } sc . Split ( w . ScanWords ) var ( args [ ] interface { } lastPos int ) seen := make ( map [ string ] bool ) for sc . Scan ( ) { word := sc . Text ( ) switch { case strings . HasSuffix ( word , " " ) : word = strings . TrimSuffix ( word , " " ) case strings . HasSuffix ( word , " " ) : word = strings . TrimSuffix ( word , " " ) case strings . HasSuffix ( word , " " ) : word = strings . TrimSuffix ( word , " " ) } if ( c . ignoreUpper && allUpper ( word ) ) || c . spelling . IsCorrect ( word ) { continue } if ! seen [ word ] { fmt . Printf ( " \n " , c . fileset . Position ( pos ) , word , where ) seen [ word ] = true } if c . show { if w . current . pos != lastPos { args = append ( args , text [ lastPos : w . current . pos ] ) } args = append ( args , c . warn ( text [ w . current . pos : w . current . pos + len ( word ) ] ) , text [ w . current . pos + len ( word ) : w . current . end ] ) lastPos = w . current . end } } if args != nil { if lastPos != len ( text ) { args = append ( args , text [ lastPos : ] ) } lines := strings . Split ( join ( args ) , " \n " ) if lines [ len ( lines ) - 1 ] == " " { lines = lines [ : len ( lines ) - 1 ] } fmt . Printf ( " \t \n " , strings . Join ( lines , " \n \t " ) ) } }
check checks the provided text and outputs information about any misspellings
in the text.
check checks the provided text and outputs information about any misspellings in the text .