1
0
mirror of https://github.com/golang/go synced 2024-11-26 20:01:19 -07:00

fix some typos in comments, remove some redundants and some always not nil checks

This commit is contained in:
kumakichi 2021-04-27 17:24:37 +08:00
parent e0815d041c
commit 3b1c7573cf
7 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ type Importer struct {
packages map[string]*types.Package
}
// NewImporter returns a new Importer for the given context, file set, and map
// New returns a new Importer for the given context, file set, and map
// of packages. The context is used to resolve import paths to package paths,
// and identifying the files belonging to the package. If the context provides
// non-nil file system functions, they are used instead of the regular package

View File

@ -90,7 +90,7 @@ func expectedErrors(fset *token.FileSet, filename string, src []byte) map[token.
if s[1] == "HERE" {
pos = here
}
errors[pos] = string(s[2])
errors[pos] = s[2]
}
case token.SEMICOLON:
// don't use the position of auto-inserted (invisible) semicolons

View File

@ -891,7 +891,7 @@ func (p *parser) parseParameters(acceptTParams bool) (tparams, params *ast.Field
rbrack := p.expect(token.RBRACK)
tparams = &ast.FieldList{Opening: opening, List: list, Closing: rbrack}
// Type parameter lists must not be empty.
if tparams != nil && tparams.NumFields() == 0 {
if tparams.NumFields() == 0 {
p.error(tparams.Closing, "empty type parameter list")
tparams = nil // avoid follow-on errors
}

View File

@ -844,7 +844,7 @@ func (p *printer) writeWhitespace(n int) {
// ----------------------------------------------------------------------------
// Printing interface
// nlines limits n to maxNewlines.
// nlimit limits n to maxNewlines.
func nlimit(n int) int {
if n > maxNewlines {
n = maxNewlines

View File

@ -86,7 +86,7 @@ func (p *ErrorList) RemoveMultiples() {
i++
}
}
(*p) = (*p)[0:i]
*p = (*p)[0:i]
}
// An ErrorList implements the error interface.

View File

@ -383,7 +383,7 @@ func (s *Scanner) digits(base int, invalid *int) (digsep int) {
if s.ch == '_' {
ds = 2
} else if s.ch >= max && *invalid < 0 {
*invalid = int(s.offset) // record invalid rune offset
*invalid = s.offset // record invalid rune offset
}
digsep |= ds
s.next()

View File

@ -215,7 +215,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeName, targs []Type,
}
// At least one type argument couldn't be inferred.
assert(targs != nil && index >= 0 && targs[index] == nil)
assert(index >= 0 && targs[index] == nil)
tpar := tparams[index]
if report {
check.errorf(posn, _Todo, "cannot infer %s (%v) (%v)", tpar.name, tpar.pos, targs)