mirror of
https://github.com/golang/go.git
synced 2024-09-22 10:58:58 +00:00
gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments. No other changes. R=r CC=golang-dev https://golang.org/cl/6815053
This commit is contained in:
parent
db2b6ed854
commit
465b9c35e5
@ -110,7 +110,7 @@ func testZeroArgCallback(t *testing.T) {
|
||||
func goFoo() {
|
||||
x := 1
|
||||
for i := 0; i < 10000; i++ {
|
||||
// variadic call mallocs + writes to
|
||||
// variadic call mallocs + writes to
|
||||
variadic(x, x, x)
|
||||
if x != 1 {
|
||||
panic("bad x")
|
||||
|
@ -6,7 +6,7 @@ package cgotest
|
||||
|
||||
import "testing"
|
||||
|
||||
// The actual test functions are in non-_test.go files
|
||||
// The actual test functions are in non-_test.go files
|
||||
// so that they can use cgo (import "C").
|
||||
// These wrappers are here for gotest to find.
|
||||
|
||||
|
@ -35,8 +35,8 @@ func BackgroundSleep(n int32) {
|
||||
}()
|
||||
}
|
||||
|
||||
// wasteCPU starts a background goroutine to waste CPU
|
||||
// to cause the power management to raise the CPU frequency.
|
||||
// wasteCPU starts a background goroutine to waste CPU
|
||||
// to cause the power management to raise the CPU frequency.
|
||||
// On ARM this has the side effect of making sleep more accurate.
|
||||
func wasteCPU() chan struct{} {
|
||||
done := make(chan struct{})
|
||||
|
@ -7,7 +7,7 @@
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
#include <dlfcn.h>
|
||||
#include <dlfcn.h>
|
||||
#cgo linux LDFLAGS: -ldl
|
||||
*/
|
||||
import "C"
|
||||
|
@ -183,7 +183,7 @@ type Result struct {
|
||||
Log string `datastore:"-"` // for JSON unmarshaling only
|
||||
LogHash string `datastore:",noindex"` // Key to the Log record.
|
||||
|
||||
RunTime int64 // time to build+test in nanoseconds
|
||||
RunTime int64 // time to build+test in nanoseconds
|
||||
}
|
||||
|
||||
func (r *Result) Key(c appengine.Context) *datastore.Key {
|
||||
|
@ -4,15 +4,15 @@
|
||||
|
||||
/*
|
||||
|
||||
Go Builder is a continuous build client for the Go project.
|
||||
Go Builder is a continuous build client for the Go project.
|
||||
It integrates with the Go Dashboard AppEngine application.
|
||||
|
||||
Go Builder is intended to run continuously as a background process.
|
||||
|
||||
It periodically pulls updates from the Go Mercurial repository.
|
||||
It periodically pulls updates from the Go Mercurial repository.
|
||||
|
||||
When a newer revision is found, Go Builder creates a clone of the repository,
|
||||
runs all.bash, and reports build success or failure to the Go Dashboard.
|
||||
runs all.bash, and reports build success or failure to the Go Dashboard.
|
||||
|
||||
For a release revision (a change description that matches "release.YYYY-MM-DD"),
|
||||
Go Builder will create a tar.gz archive of the GOROOT and deliver it to the
|
||||
@ -22,7 +22,7 @@ Usage:
|
||||
|
||||
gobuilder goos-goarch...
|
||||
|
||||
Several goos-goarch combinations can be provided, and the builder will
|
||||
Several goos-goarch combinations can be provided, and the builder will
|
||||
build them in serial.
|
||||
|
||||
Optional flags:
|
||||
|
@ -29,7 +29,7 @@ func run(timeout time.Duration, envv []string, dir string, argv ...string) error
|
||||
return waitWithTimeout(timeout, cmd)
|
||||
}
|
||||
|
||||
// runLog runs a process and returns the combined stdout/stderr,
|
||||
// runLog runs a process and returns the combined stdout/stderr,
|
||||
// as well as writing it to logfile (if specified). It returns
|
||||
// process combined stdout and stderr output, exit status and error.
|
||||
// The error returned is nil, if process is started successfully,
|
||||
|
@ -208,7 +208,7 @@ func NewBuilder(builder string) (*Builder, error) {
|
||||
}
|
||||
|
||||
// build checks for a new commit for this builder
|
||||
// and builds it if one is found.
|
||||
// and builds it if one is found.
|
||||
// It returns true if a build was attempted.
|
||||
func (b *Builder) build() bool {
|
||||
hash, err := b.todo("build-go-commit", "", "")
|
||||
@ -286,7 +286,7 @@ func (b *Builder) buildHash(hash string) error {
|
||||
}
|
||||
|
||||
// failBuild checks for a new commit for this builder
|
||||
// and fails it if one is found.
|
||||
// and fails it if one is found.
|
||||
// It returns true if a build was "attempted".
|
||||
func (b *Builder) failBuild() bool {
|
||||
hash, err := b.todo("build-go-commit", "", "")
|
||||
|
@ -434,7 +434,7 @@ func updateCL(c appengine.Context, n string) error {
|
||||
// trailingSpaceRE matches trailing spaces.
|
||||
var trailingSpaceRE = regexp.MustCompile(`(?m)[ \t\r]+$`)
|
||||
|
||||
// removeRE is the list of patterns to skip over at the beginning of a
|
||||
// removeRE is the list of patterns to skip over at the beginning of a
|
||||
// message when looking for message text.
|
||||
var removeRE = regexp.MustCompile(`(?m-s)\A(` +
|
||||
// Skip leading "Hello so-and-so," generated by codereview plugin.
|
||||
|
@ -4,20 +4,20 @@
|
||||
|
||||
// Goplay is a web interface for experimenting with Go code.
|
||||
// It is similar to the Go Playground: http://golang.org/doc/play/
|
||||
//
|
||||
//
|
||||
// To use goplay:
|
||||
// $ cd $GOROOT/misc/goplay
|
||||
// $ go run goplay.go
|
||||
// and load http://localhost:3999/ in a web browser.
|
||||
//
|
||||
//
|
||||
// You should see a Hello World program, which you can compile and run by
|
||||
// pressing shift-enter. There is also a "compile-on-keypress" feature that can
|
||||
// be enabled by checking a checkbox.
|
||||
//
|
||||
//
|
||||
// WARNING! CUIDADO! ACHTUNG! ATTENZIONE!
|
||||
// A note on security: anyone with access to the goplay web interface can run
|
||||
// arbitrary code on your computer. Goplay is not a sandbox, and has no other
|
||||
// security mechanisms. Do not deploy it in untrusted environments.
|
||||
// By default, goplay listens only on localhost. This can be overridden with
|
||||
// security mechanisms. Do not deploy it in untrusted environments.
|
||||
// By default, goplay listens only on localhost. This can be overridden with
|
||||
// the -http parameter. Do so at your own risk.
|
||||
package documentation
|
||||
|
@ -44,7 +44,7 @@ func main() {
|
||||
log.Fatal(http.ListenAndServe(*httpListen, nil))
|
||||
}
|
||||
|
||||
// FrontPage is an HTTP handler that renders the goplay interface.
|
||||
// FrontPage is an HTTP handler that renders the goplay interface.
|
||||
// If a filename is supplied in the path component of the URI,
|
||||
// its contents will be put in the interface's text area.
|
||||
// Otherwise, the default "hello, world" program is displayed.
|
||||
|
@ -1562,7 +1562,7 @@ func godefsFields(fld []*ast.Field) {
|
||||
}
|
||||
|
||||
// fieldPrefix returns the prefix that should be removed from all the
|
||||
// field names when generating the C or Go code. For generated
|
||||
// field names when generating the C or Go code. For generated
|
||||
// C, we leave the names as is (tv_sec, tv_usec), since that's what
|
||||
// people are used to seeing in C. For generated Go code, such as
|
||||
// package syscall's data structures, we drop a common prefix
|
||||
@ -1579,7 +1579,7 @@ func fieldPrefix(fld []*ast.Field) string {
|
||||
// named, say, _pad in an otherwise prefixed header.
|
||||
// If the struct has 3 fields tv_sec, tv_usec, _pad1, then we
|
||||
// still want to remove the tv_ prefix.
|
||||
// The check for "orig_" here handles orig_eax in the
|
||||
// The check for "orig_" here handles orig_eax in the
|
||||
// x86 ptrace register sets, which otherwise have all fields
|
||||
// with reg_ prefixes.
|
||||
if strings.HasPrefix(n.Name, "orig_") || strings.HasPrefix(n.Name, "_") {
|
||||
|
@ -91,7 +91,7 @@ func isCreateFlag(flag ast.Expr) bool {
|
||||
case "O_TRUNC":
|
||||
foundTrunc = true
|
||||
case "O_RDONLY", "O_WRONLY", "O_RDWR":
|
||||
// okay
|
||||
// okay
|
||||
default:
|
||||
// Unexpected flag, like O_APPEND or O_EXCL.
|
||||
// Be conservative and do not rewrite.
|
||||
|
@ -42,7 +42,7 @@ http://codereview.appspot.com/4433066
|
||||
//
|
||||
// If z is an ordinary variable name and x is not subsequently assigned to,
|
||||
// references to x can be replaced by z and the assignment deleted.
|
||||
// We only bother if x and z are the same name.
|
||||
// We only bother if x and z are the same name.
|
||||
// If y is not subsequently assigned to and neither is x, references to
|
||||
// y can be replaced by its expression. We only bother when there is
|
||||
// just one use or when the use appears in an if clause.
|
||||
@ -76,14 +76,14 @@ http://codereview.appspot.com/4433066
|
||||
//
|
||||
// Because the type check assignment includes a type assertion in its
|
||||
// syntax and the rewrite traversal is bottom up, we must do a pass to
|
||||
// rewrite the type check assignments and then a separate pass to
|
||||
// rewrite the type check assignments and then a separate pass to
|
||||
// rewrite the type assertions.
|
||||
//
|
||||
// The same process applies to the API changes for reflect.Value.
|
||||
//
|
||||
// For both cases, but especially Value, the code needs to be aware
|
||||
// of the type of a receiver when rewriting a method call. For example,
|
||||
// x.(*reflect.ArrayValue).Elem(i) becomes x.Index(i) while
|
||||
// x.(*reflect.ArrayValue).Elem(i) becomes x.Index(i) while
|
||||
// x.(*reflect.MapValue).Elem(v) becomes x.MapIndex(v).
|
||||
// In general, reflectFn needs to know the type of the receiver expression.
|
||||
// In most cases (and in all the cases in the Go source tree), the toy
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
//
|
||||
// The fact that it is partial is very important: the input is
|
||||
// an AST and a description of some type information to
|
||||
// assume about one or more packages, but not all the
|
||||
// assume about one or more packages, but not all the
|
||||
// packages that the program imports. The checker is
|
||||
// expected to do as much as it can with what it has been
|
||||
// given. There is not enough information supplied to do
|
||||
|
@ -1120,7 +1120,7 @@ func (b *builder) runOut(dir string, desc string, cmdargs ...interface{}) ([]byt
|
||||
// not worry about other processes inheriting the fd accidentally.
|
||||
// The answer is that running a command is fork and exec.
|
||||
// A child forked while the cgo fd is open inherits that fd.
|
||||
// Until the child has called exec, it holds the fd open and the
|
||||
// Until the child has called exec, it holds the fd open and the
|
||||
// kernel will not let us run cgo. Even if the child were to close
|
||||
// the fd explicitly, it would still be open from the time of the fork
|
||||
// until the time of the explicit close, and the race would remain.
|
||||
|
@ -493,7 +493,7 @@ Here's an example directory layout:
|
||||
bar.a (installed package object)
|
||||
|
||||
Go searches each directory listed in GOPATH to find source code,
|
||||
but new packages are always downloaded into the first directory
|
||||
but new packages are always downloaded into the first directory
|
||||
in the list.
|
||||
|
||||
|
||||
@ -511,13 +511,13 @@ denotes the package in that directory.
|
||||
|
||||
Otherwise, the import path P denotes the package found in
|
||||
the directory DIR/src/P for some DIR listed in the GOPATH
|
||||
environment variable (see 'go help gopath').
|
||||
environment variable (see 'go help gopath').
|
||||
|
||||
If no import paths are given, the action applies to the
|
||||
package in the current directory.
|
||||
|
||||
The special import path "all" expands to all package directories
|
||||
found in all the GOPATH trees. For example, 'go list all'
|
||||
found in all the GOPATH trees. For example, 'go list all'
|
||||
lists all the packages on the local system.
|
||||
|
||||
The special import path "std" is like all but expands to just the
|
||||
|
@ -105,7 +105,7 @@ func downloadPaths(args []string) []string {
|
||||
if strings.Contains(a, "...") {
|
||||
var expand []string
|
||||
// Use matchPackagesInFS to avoid printing
|
||||
// warnings. They will be printed by the
|
||||
// warnings. They will be printed by the
|
||||
// eventual call to importPaths instead.
|
||||
if build.IsLocalImport(a) {
|
||||
expand = matchPackagesInFS(a)
|
||||
|
@ -124,7 +124,7 @@ func testFlags(args []string) (packageNames, passToTest []string) {
|
||||
f, value, extraWord := testFlag(args, i)
|
||||
if f == nil {
|
||||
// This is a flag we do not know; we must assume
|
||||
// that any args we see after this might be flag
|
||||
// that any args we see after this might be flag
|
||||
// arguments, not package names.
|
||||
inPkg = false
|
||||
if packageNames == nil {
|
||||
|
@ -264,7 +264,7 @@ type DirEntry struct {
|
||||
Height int // = DirList.MaxHeight - Depth, > 0
|
||||
Path string // directory path; includes Name, relative to DirList root
|
||||
Name string // directory name
|
||||
HasPkg bool // true if the directory contains at least one package
|
||||
HasPkg bool // true if the directory contains at least one package
|
||||
Synopsis string // package documentation, if any
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ import (
|
||||
// paths can assume they are slash-separated and should be using
|
||||
// package path (often imported as pathpkg) to manipulate them,
|
||||
// even on Windows.
|
||||
//
|
||||
//
|
||||
var fs = nameSpace{} // the underlying file system for godoc
|
||||
|
||||
// Setting debugNS = true will enable debugging prints about
|
||||
@ -138,7 +138,7 @@ func hasPathPrefix(x, y string) bool {
|
||||
// but we want to be able to mount multiple file systems on a single
|
||||
// mount point and have the system behave as if the union of those
|
||||
// file systems were present at the mount point.
|
||||
// For example, if the OS file system has a Go installation in
|
||||
// For example, if the OS file system has a Go installation in
|
||||
// c:\Go and additional Go path trees in d:\Work1 and d:\Work2, then
|
||||
// this name space creates the view we want for the godoc server:
|
||||
//
|
||||
@ -179,7 +179,7 @@ func hasPathPrefix(x, y string) bool {
|
||||
// OS(`d:\Work1').ReadDir("/src/code")
|
||||
// OS(`d:\Work2').ReadDir("/src/code")
|
||||
//
|
||||
// Note that the "/src/pkg" in "/src/pkg/code" has been replaced by
|
||||
// Note that the "/src/pkg" in "/src/pkg/code" has been replaced by
|
||||
// just "/src" in the final two calls.
|
||||
//
|
||||
// OS is itself an implementation of a file system: it implements
|
||||
|
@ -121,7 +121,7 @@ func FormatSelections(w io.Writer, text []byte, lw LinkWriter, links Selection,
|
||||
} else {
|
||||
// we have a selection change:
|
||||
// format the previous selection segment, determine
|
||||
// the new selection bitset and start a new segment
|
||||
// the new selection bitset and start a new segment
|
||||
segment(offs)
|
||||
lastOffs = offs
|
||||
mask := 1 << uint(index)
|
||||
|
@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Template support for writing HTML documents.
|
||||
// Documents that include Template: true in their
|
||||
// Documents that include Template: true in their
|
||||
// metadata are executed as input to text/template.
|
||||
//
|
||||
// This file defines functions for those templates to invoke.
|
||||
|
@ -11,7 +11,7 @@ Nm is a version of the Plan 9 nm command. The original is documented at
|
||||
It prints the name list (symbol table) for programs compiled by gc as well as the
|
||||
Plan 9 C compiler.
|
||||
|
||||
This implementation adds the flag -S, which prints each symbol's size
|
||||
This implementation adds the flag -S, which prints each symbol's size
|
||||
in decimal after its address.
|
||||
|
||||
Usage:
|
||||
|
@ -35,7 +35,7 @@ Printf.
|
||||
|
||||
Non-standard signatures for methods with familiar names, including:
|
||||
Format GobEncode GobDecode MarshalJSON MarshalXML
|
||||
Peek ReadByte ReadFrom ReadRune Scan Seek
|
||||
Peek ReadByte ReadFrom ReadRune Scan Seek
|
||||
UnmarshalJSON UnreadByte UnreadRune WriteByte
|
||||
WriteTo
|
||||
|
||||
|
@ -174,7 +174,7 @@ func (w *Writer) Create(name string) (io.Writer, error) {
|
||||
}
|
||||
|
||||
// CreateHeader adds a file to the zip file using the provided FileHeader
|
||||
// for the file metadata.
|
||||
// for the file metadata.
|
||||
// It returns a Writer to which the file contents should be written.
|
||||
// The file's contents must be written to the io.Writer before the next
|
||||
// call to Create, CreateHeader, or Close.
|
||||
|
@ -1026,7 +1026,7 @@ func TestEqualFold(t *testing.T) {
|
||||
|
||||
var makeFieldsInput = func() []byte {
|
||||
x := make([]byte, 1<<20)
|
||||
// Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
|
||||
// Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
|
||||
for i := range x {
|
||||
switch rand.Intn(10) {
|
||||
case 0:
|
||||
|
@ -20,7 +20,7 @@ type bitReader struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// newBitReader returns a new bitReader reading from r. If r is not
|
||||
// newBitReader returns a new bitReader reading from r. If r is not
|
||||
// already an io.ByteReader, it will be converted via a bufio.Reader.
|
||||
func newBitReader(r io.Reader) bitReader {
|
||||
byter, ok := r.(io.ByteReader)
|
||||
|
@ -61,7 +61,7 @@ type PrivateKey struct {
|
||||
}
|
||||
|
||||
type PrecomputedValues struct {
|
||||
Dp, Dq *big.Int // D mod (P-1) (or mod Q-1)
|
||||
Dp, Dq *big.Int // D mod (P-1) (or mod Q-1)
|
||||
Qinv *big.Int // Q^-1 mod Q
|
||||
|
||||
// CRTValues is used for the 3rd and subsequent primes. Due to a
|
||||
|
@ -513,7 +513,7 @@ Again:
|
||||
// First message, be extra suspicious:
|
||||
// this might not be a TLS client.
|
||||
// Bail out before reading a full 'body', if possible.
|
||||
// The current max version is 3.1.
|
||||
// The current max version is 3.1.
|
||||
// If the version is >= 16.0, it's probably not real.
|
||||
// Similarly, a clientHello message encodes in
|
||||
// well under a kilobyte. If the length is >= 12 kB,
|
||||
|
@ -103,7 +103,7 @@ func (s *CertPool) AppendCertsFromPEM(pemCerts []byte) (ok bool) {
|
||||
}
|
||||
|
||||
// Subjects returns a list of the DER-encoded subjects of
|
||||
// all of the certificates in the pool.
|
||||
// all of the certificates in the pool.
|
||||
func (s *CertPool) Subjects() (res [][]byte) {
|
||||
res = make([][]byte, len(s.certs))
|
||||
for i, c := range s.certs {
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// pkcs8 reflects an ASN.1, PKCS#8 PrivateKey. See
|
||||
// pkcs8 reflects an ASN.1, PKCS#8 PrivateKey. See
|
||||
// ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-8/pkcs-8v1_2.asn.
|
||||
type pkcs8 struct {
|
||||
Version int
|
||||
|
@ -156,8 +156,8 @@ const (
|
||||
//
|
||||
// pkcs-1 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// RFC 3279 2.2.1 RSA Signature Algorithms
|
||||
//
|
||||
// md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 }
|
||||
@ -165,19 +165,19 @@ const (
|
||||
// md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 }
|
||||
//
|
||||
// sha-1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 }
|
||||
//
|
||||
//
|
||||
// dsaWithSha1 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 3 }
|
||||
// iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 3 }
|
||||
//
|
||||
// RFC 3279 2.2.3 ECDSA Signature Algorithm
|
||||
//
|
||||
//
|
||||
// ecdsa-with-SHA1 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) ansi-x962(10045)
|
||||
// signatures(4) ecdsa-with-SHA1(1)}
|
||||
//
|
||||
//
|
||||
// RFC 4055 5 PKCS #1 Version 1.5
|
||||
//
|
||||
//
|
||||
// sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 }
|
||||
//
|
||||
// sha384WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 12 }
|
||||
|
@ -132,7 +132,7 @@ func (enc *Encoder) sendActualType(w io.Writer, state *encoderState, ut *userTyp
|
||||
return true
|
||||
}
|
||||
|
||||
// sendType sends the type info to the other side, if necessary.
|
||||
// sendType sends the type info to the other side, if necessary.
|
||||
func (enc *Encoder) sendType(w io.Writer, state *encoderState, origt reflect.Type) (sent bool) {
|
||||
ut := userType(origt)
|
||||
if ut.isGobEncoder {
|
||||
|
@ -86,7 +86,7 @@ import (
|
||||
//
|
||||
// Anonymous struct fields are usually marshaled as if their inner exported fields
|
||||
// were fields in the outer struct, subject to the usual Go visibility rules.
|
||||
// An anonymous struct field with a name given in its JSON tag is treated as
|
||||
// An anonymous struct field with a name given in its JSON tag is treated as
|
||||
// having that name instead of as anonymous.
|
||||
//
|
||||
// Handling of anonymous struct fields is new in Go 1.1.
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// parseDoctype parses the data from a DoctypeToken into a name,
|
||||
// public identifier, and system identifier. It returns a Node whose Type
|
||||
// public identifier, and system identifier. It returns a Node whose Type
|
||||
// is DoctypeNode, whose Data is the name, and which has attributes
|
||||
// named "system" and "public" for the two identifiers if they were present.
|
||||
// quirks is whether the document should be parsed in "quirks mode".
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// These replacements permit compatibility with old numeric entities that
|
||||
// These replacements permit compatibility with old numeric entities that
|
||||
// assumed Windows-1252 encoding.
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#consume-a-character-reference
|
||||
var replacementTable = [...]rune{
|
||||
@ -46,7 +46,7 @@ var replacementTable = [...]rune{
|
||||
'\u009D',
|
||||
'\u017E',
|
||||
'\u0178', // Last entry is 0x9F.
|
||||
// 0x00->'\uFFFD' is handled programmatically.
|
||||
// 0x00->'\uFFFD' is handled programmatically.
|
||||
// 0x0D->'\u000D' is a no-op.
|
||||
}
|
||||
|
||||
|
@ -2027,7 +2027,7 @@ func Parse(r io.Reader) (*Node, error) {
|
||||
return p.doc, nil
|
||||
}
|
||||
|
||||
// ParseFragment parses a fragment of HTML and returns the nodes that were
|
||||
// ParseFragment parses a fragment of HTML and returns the nodes that were
|
||||
// found. If the fragment is the InnerHTML for an existing element, pass that
|
||||
// element in context.
|
||||
func ParseFragment(r io.Reader, context *Node) ([]*Node, error) {
|
||||
|
@ -35,7 +35,7 @@ type writer interface {
|
||||
// children; the <a> is reparented to the <table>'s parent. However, calling
|
||||
// Parse on "<a><table><a>" does not return an error, but the result has an <a>
|
||||
// element with an <a> child, and is therefore not 'well-formed'.
|
||||
//
|
||||
//
|
||||
// Programmatically constructed trees are typically also 'well-formed', but it
|
||||
// is possible to construct a tree that looks innocuous but, when rendered and
|
||||
// re-parsed, results in a different tree. A simple example is that a solitary
|
||||
@ -53,7 +53,7 @@ func Render(w io.Writer, n *Node) error {
|
||||
return buf.Flush()
|
||||
}
|
||||
|
||||
// plaintextAbort is returned from render1 when a <plaintext> element
|
||||
// plaintextAbort is returned from render1 when a <plaintext> element
|
||||
// has been rendered. No more end tags should be rendered after that.
|
||||
var plaintextAbort = errors.New("html: internal error (plaintext abort)")
|
||||
|
||||
|
@ -320,7 +320,7 @@ loop:
|
||||
}
|
||||
|
||||
// readRawEndTag attempts to read a tag like "</foo>", where "foo" is z.rawTag.
|
||||
// If it succeeds, it backs up the input position to reconsume the tag and
|
||||
// If it succeeds, it backs up the input position to reconsume the tag and
|
||||
// returns true. Otherwise it returns false. The opening "</" has already been
|
||||
// consumed.
|
||||
func (z *Tokenizer) readRawEndTag() bool {
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
// compacted.
|
||||
// - Compress secondary weights into 8 bits.
|
||||
// - Some LDML specs specify a context element. Currently we simply concatenate
|
||||
// those. Context can be implemented using the contraction trie. If Builder
|
||||
// those. Context can be implemented using the contraction trie. If Builder
|
||||
// could analyze and detect when using a context makes sense, there is no
|
||||
// need to expose this construct in the API.
|
||||
|
||||
@ -72,7 +72,7 @@ func NewBuilder() *Builder {
|
||||
}
|
||||
}
|
||||
|
||||
// Tailoring returns a Tailoring for the given locale. One should
|
||||
// Tailoring returns a Tailoring for the given locale. One should
|
||||
// have completed all calls to Add before calling Tailoring.
|
||||
func (b *Builder) Tailoring(locale string) *Tailoring {
|
||||
t := &Tailoring{
|
||||
@ -84,7 +84,7 @@ func (b *Builder) Tailoring(locale string) *Tailoring {
|
||||
return t
|
||||
}
|
||||
|
||||
// Add adds an entry to the collation element table, mapping
|
||||
// Add adds an entry to the collation element table, mapping
|
||||
// a slice of runes to a sequence of collation elements.
|
||||
// A collation element is specified as list of weights: []int{primary, secondary, ...}.
|
||||
// The entries are typically obtained from a collation element table
|
||||
@ -171,7 +171,7 @@ func (t *Tailoring) SetAnchorBefore(anchor string) error {
|
||||
// See http://www.unicode.org/reports/tr10/#Tailoring_Example for details
|
||||
// on parametric tailoring and http://unicode.org/reports/tr35/#Collation_Elements
|
||||
// for full details on LDML.
|
||||
//
|
||||
//
|
||||
// Examples: create a tailoring for Swedish, where "ä" is ordered after "z"
|
||||
// at the primary sorting level:
|
||||
// t := b.Tailoring("se")
|
||||
|
@ -132,7 +132,7 @@ func makeExpandIndex(index int) (uint32, error) {
|
||||
return expandID + uint32(index), nil
|
||||
}
|
||||
|
||||
// Each list of collation elements corresponding to an expansion starts with
|
||||
// Each list of collation elements corresponding to an expansion starts with
|
||||
// a header indicating the length of the sequence.
|
||||
func makeExpansionHeader(n int) (uint32, error) {
|
||||
return uint32(n), nil
|
||||
@ -199,7 +199,7 @@ func implicitPrimary(r rune) int {
|
||||
return int(r) + otherOffset
|
||||
}
|
||||
|
||||
// convertLargeWeights converts collation elements with large
|
||||
// convertLargeWeights converts collation elements with large
|
||||
// primaries (either double primaries or for illegal runes)
|
||||
// to our own representation.
|
||||
// A CJK character C is represented in the DUCET as
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
// This file contains code for detecting contractions and generating
|
||||
// the necessary tables.
|
||||
// Any Unicode Collation Algorithm (UCA) table entry that has more than
|
||||
// one rune one the left-hand side is called a contraction.
|
||||
// one rune one the left-hand side is called a contraction.
|
||||
// See http://www.unicode.org/reports/tr10/#Contractions for more details.
|
||||
//
|
||||
// We define the following terms:
|
||||
@ -27,7 +27,7 @@ import (
|
||||
// A rune may be both a initial and a non-initial and may be so in
|
||||
// many contractions. An initial may typically also appear by itself.
|
||||
// In case of ambiguities, the UCA requires we match the longest
|
||||
// contraction.
|
||||
// contraction.
|
||||
//
|
||||
// Many contraction rules share the same set of possible suffixes.
|
||||
// We store sets of suffixes in a trie that associates an index with
|
||||
@ -39,14 +39,14 @@ import (
|
||||
// is represented as a subsequence of ctEntries, where each entry corresponds to
|
||||
// a possible match of a next character in the search string. An entry
|
||||
// also includes the length and offset to the next sequence of entries
|
||||
// to check in case of a match.
|
||||
// to check in case of a match.
|
||||
|
||||
const (
|
||||
final = 0
|
||||
noIndex = 0xFF
|
||||
)
|
||||
|
||||
// ctEntry associates to a matching byte an offset and/or next sequence of
|
||||
// ctEntry associates to a matching byte an offset and/or next sequence of
|
||||
// bytes to check. A ctEntry c is called final if a match means that the
|
||||
// longest suffix has been found. An entry c is final if c.n == 0.
|
||||
// A single final entry can match a range of characters to an offset.
|
||||
@ -58,7 +58,7 @@ const (
|
||||
// {'a', 1, 1, noIndex}, // 'a' by itself does not match, so i is 0xFF.
|
||||
// {'b', 'c', 0, 1}, // "ab" -> 1, "ac" -> 2
|
||||
// }
|
||||
//
|
||||
//
|
||||
// The suffix strings "ab", "abc", "abd", and "abcd" can be represented as:
|
||||
// []ctEntry{
|
||||
// {'a', 1, 1, noIndex}, // 'a' must be followed by 'b'.
|
||||
@ -72,7 +72,7 @@ type ctEntry struct {
|
||||
l uint8 // non-final: byte value to match; final: lowest match in range.
|
||||
h uint8 // non-final: relative index to next block; final: highest match in range.
|
||||
n uint8 // non-final: length of next block; final: final
|
||||
i uint8 // result offset. Will be noIndex if more bytes are needed to complete.
|
||||
i uint8 // result offset. Will be noIndex if more bytes are needed to complete.
|
||||
}
|
||||
|
||||
// contractTrieSet holds a set of contraction tries. The tries are stored
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// The trie in this file is used to associate the first full character
|
||||
// in a UTF-8 string to a collation element.
|
||||
// All but the last byte in a UTF-8 byte sequence are
|
||||
// All but the last byte in a UTF-8 byte sequence are
|
||||
// used to look up offsets in the index table to be used for the next byte.
|
||||
// The last byte is used to index into a table of collation elements.
|
||||
// This file contains the code for the generation of the trie.
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// We take the smallest, largest and an arbitrary value for each
|
||||
// We take the smallest, largest and an arbitrary value for each
|
||||
// of the UTF-8 sequence lengths.
|
||||
var testRunes = []rune{
|
||||
0x01, 0x0C, 0x7F, // 1-byte sequences
|
||||
|
@ -30,7 +30,7 @@ const (
|
||||
|
||||
// AlternateHandling identifies the various ways in which variables are handled.
|
||||
// A rune with a primary weight lower than the variable top is considered a
|
||||
// variable.
|
||||
// variable.
|
||||
// See http://www.unicode.org/reports/tr10/#Variable_Weighting for details.
|
||||
type AlternateHandling int
|
||||
|
||||
|
@ -37,9 +37,9 @@ func (t *table) indexedTable(idx tableIndex) *table {
|
||||
return &nt
|
||||
}
|
||||
|
||||
// appendNext appends the weights corresponding to the next rune or
|
||||
// appendNext appends the weights corresponding to the next rune or
|
||||
// contraction in s. If a contraction is matched to a discontinuous
|
||||
// sequence of runes, the weights for the interstitial runes are
|
||||
// sequence of runes, the weights for the interstitial runes are
|
||||
// appended as well. It returns a new slice that includes the appended
|
||||
// weights and the number of bytes consumed from s.
|
||||
func (t *table) appendNext(w []weights, s []byte) ([]weights, int) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// The trie in this file is used to associate the first full character
|
||||
// in an UTF-8 string to a collation element.
|
||||
// All but the last byte in a UTF-8 byte sequence are
|
||||
// All but the last byte in a UTF-8 byte sequence are
|
||||
// used to lookup offsets in the index table to be used for the next byte.
|
||||
// The last byte is used to index into a table of collation elements.
|
||||
// For a full description, see exp/locale/collate/build/trie.go.
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// We take the smallest, largest and an arbitrary value for each
|
||||
// We take the smallest, largest and an arbitrary value for each
|
||||
// of the UTF-8 sequence lengths.
|
||||
var testRunes = []rune{
|
||||
0x01, 0x0C, 0x7F, // 1-byte sequences
|
||||
|
@ -76,7 +76,7 @@ func init() {
|
||||
// We do not distinguish between boundaries for NFC, NFD, etc. to avoid
|
||||
// unexpected behavior for the user. For example, in NFD, there is a boundary
|
||||
// after 'a'. However, 'a' might combine with modifiers, so from the application's
|
||||
// perspective it is not a good boundary. We will therefore always use the
|
||||
// perspective it is not a good boundary. We will therefore always use the
|
||||
// boundaries for the combining variants.
|
||||
|
||||
// BoundaryBefore returns true if this rune starts a new segment and
|
||||
@ -101,7 +101,7 @@ func (p Properties) BoundaryAfter() bool {
|
||||
// 0: NFD_QC Yes (0) or No (1). No also means there is a decomposition.
|
||||
// 1..2: NFC_QC Yes(00), No (10), or Maybe (11)
|
||||
// 3: Combines forward (0 == false, 1 == true)
|
||||
//
|
||||
//
|
||||
// When all 4 bits are zero, the character is inert, meaning it is never
|
||||
// influenced by normalization.
|
||||
type qcInfo uint8
|
||||
|
@ -64,9 +64,9 @@ func (i *Iter) Done() bool {
|
||||
}
|
||||
|
||||
// Next writes f(i.input[i.Pos():n]...) to buffer buf, where n is the
|
||||
// largest boundary of i.input such that the result fits in buf.
|
||||
// largest boundary of i.input such that the result fits in buf.
|
||||
// It returns the number of bytes written to buf.
|
||||
// len(buf) should be at least MaxSegmentSize.
|
||||
// len(buf) should be at least MaxSegmentSize.
|
||||
// Done must be false before calling Next.
|
||||
func (i *Iter) Next(buf []byte) int {
|
||||
return i.next(i, buf)
|
||||
|
@ -86,7 +86,7 @@ const (
|
||||
// Quick Check properties of runes allow us to quickly
|
||||
// determine whether a rune may occur in a normal form.
|
||||
// For a given normal form, a rune may be guaranteed to occur
|
||||
// verbatim (QC=Yes), may or may not combine with another
|
||||
// verbatim (QC=Yes), may or may not combine with another
|
||||
// rune (QC=Maybe), or may not occur (QC=No).
|
||||
type QCResult int
|
||||
|
||||
|
@ -16,7 +16,7 @@ func main() {
|
||||
printTestTables()
|
||||
}
|
||||
|
||||
// We take the smallest, largest and an arbitrary value for each
|
||||
// We take the smallest, largest and an arbitrary value for each
|
||||
// of the UTF-8 sequence lengths.
|
||||
var testRunes = []rune{
|
||||
0x01, 0x0C, 0x7F, // 1-byte sequences
|
||||
|
@ -57,7 +57,7 @@ var logger = log.New(os.Stderr, "", log.Lshortfile)
|
||||
// 1E0A;1E0A;0044 0307;1E0A;0044 0307; # (Ḋ; Ḋ; D◌̇; Ḋ; D◌̇; ) LATIN CAPITAL LETTER D WITH DOT ABOVE
|
||||
// 1E0C;1E0C;0044 0323;1E0C;0044 0323; # (Ḍ; Ḍ; D◌̣; Ḍ; D◌̣; ) LATIN CAPITAL LETTER D WITH DOT BELOW
|
||||
//
|
||||
// Each test has 5 columns (c1, c2, c3, c4, c5), where
|
||||
// Each test has 5 columns (c1, c2, c3, c4, c5), where
|
||||
// (c1, c2, c3, c4, c5) == (c1, NFC(c1), NFD(c1), NFKC(c1), NFKD(c1))
|
||||
//
|
||||
// CONFORMANCE:
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
// required to represent the constant, independent of actual
|
||||
// type. Non-numeric constants are always normalized.
|
||||
|
||||
// Representation of complex numbers.
|
||||
// Representation of complex numbers.
|
||||
type complex struct {
|
||||
re, im *big.Rat
|
||||
}
|
||||
@ -313,7 +313,7 @@ func complexity(x interface{}) int {
|
||||
// matchConst returns the matching representation (same type) with the
|
||||
// smallest complexity for two constant values x and y. They must be
|
||||
// of the same "kind" (boolean, numeric, string, or nilType).
|
||||
//
|
||||
//
|
||||
func matchConst(x, y interface{}) (_, _ interface{}) {
|
||||
if complexity(x) > complexity(y) {
|
||||
y, x = matchConst(y, x)
|
||||
|
@ -559,7 +559,7 @@ func (check *checker) exprOrType(x *operand, e ast.Expr, hint Type, iota int, cy
|
||||
switch typ := x.typ.(type) {
|
||||
case *Struct:
|
||||
if fld := lookupField(typ, e.Sel.Name); fld != nil {
|
||||
// TODO(gri) only variable if struct is variable
|
||||
// TODO(gri) only variable if struct is variable
|
||||
x.mode = variable
|
||||
x.expr = e
|
||||
x.typ = fld.Type
|
||||
|
@ -80,7 +80,7 @@ func (x *operand) String() string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// setConst sets x to the untyped constant for literal lit.
|
||||
// setConst sets x to the untyped constant for literal lit.
|
||||
func (x *operand) setConst(tok token.Token, lit string) {
|
||||
x.mode = invalid
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
%X base 16, with upper-case letters for A-F
|
||||
%U Unicode format: U+1234; same as "U+%04X"
|
||||
Floating-point and complex constituents:
|
||||
%b decimalless scientific notation with exponent a power of two,
|
||||
in the manner of strconv.FormatFloat with the 'b' format,
|
||||
%b decimalless scientific notation with exponent a power of two,
|
||||
in the manner of strconv.FormatFloat with the 'b' format,
|
||||
e.g. -123456p-78
|
||||
%e scientific notation, e.g. -1234.456e+78
|
||||
%E scientific notation, e.g. -1234.456E+78
|
||||
|
@ -231,7 +231,7 @@ func Sprintf(format string, a ...interface{}) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// Errorf formats according to a format specifier and returns the string
|
||||
// Errorf formats according to a format specifier and returns the string
|
||||
// as a value that satisfies error.
|
||||
func Errorf(format string, a ...interface{}) error {
|
||||
return errors.New(Sprintf(format, a...))
|
||||
|
@ -33,8 +33,8 @@ type ScanState interface {
|
||||
ReadRune() (r rune, size int, err error)
|
||||
// UnreadRune causes the next call to ReadRune to return the same rune.
|
||||
UnreadRune() error
|
||||
// SkipSpace skips space in the input. Newlines are treated as space
|
||||
// unless the scan operation is Scanln, Fscanln or Sscanln, in which case
|
||||
// SkipSpace skips space in the input. Newlines are treated as space
|
||||
// unless the scan operation is Scanln, Fscanln or Sscanln, in which case
|
||||
// a newline is treated as EOF.
|
||||
SkipSpace()
|
||||
// Token skips space in the input if skipSpace is true, then returns the
|
||||
@ -312,7 +312,7 @@ func notSpace(r rune) bool {
|
||||
return !isSpace(r)
|
||||
}
|
||||
|
||||
// skipSpace provides Scan() methods the ability to skip space and newline characters
|
||||
// skipSpace provides Scan() methods the ability to skip space and newline characters
|
||||
// in keeping with the current scanning mode set by format strings and Scan()/Scanln().
|
||||
func (s *ss) SkipSpace() {
|
||||
s.skipSpace(false)
|
||||
|
@ -99,7 +99,7 @@ func (r *commentListReader) next() {
|
||||
|
||||
// A nodeStack keeps track of nested nodes.
|
||||
// A node lower on the stack lexically contains the nodes higher on the stack.
|
||||
//
|
||||
//
|
||||
type nodeStack []Node
|
||||
|
||||
// push pops all nodes that appear lexically before n
|
||||
@ -113,7 +113,7 @@ func (s *nodeStack) push(n Node) {
|
||||
// pop pops all nodes that appear lexically before pos
|
||||
// (i.e., whose lexical extent has ended before or at pos).
|
||||
// It returns the last node popped.
|
||||
//
|
||||
//
|
||||
func (s *nodeStack) pop(pos token.Pos) (top Node) {
|
||||
i := len(*s)
|
||||
for i > 0 && (*s)[i-1].End() <= pos {
|
||||
|
@ -414,7 +414,7 @@ func MergePackageFiles(pkg *Package, mode MergeMode) *File {
|
||||
if path := imp.Path.Value; !seen[path] {
|
||||
// TODO: consider handling cases where:
|
||||
// - 2 imports exist with the same import path but
|
||||
// have different local names (one should probably
|
||||
// have different local names (one should probably
|
||||
// keep both of them)
|
||||
// - 2 imports exist but only one has a comment
|
||||
// - 2 imports exist and they both have (possibly
|
||||
|
@ -57,7 +57,7 @@ func resolve(scope *Scope, ident *Ident) bool {
|
||||
// An Importer must determine the canonical import path and
|
||||
// check the map to see if it is already present in the imports map.
|
||||
// If so, the Importer can return the map entry. Otherwise, the
|
||||
// Importer should load the package data for the given path into
|
||||
// Importer should load the package data for the given path into
|
||||
// a new *Object (pkg), record pkg in the imports map, and then
|
||||
// return pkg.
|
||||
type Importer func(imports map[string]*Object, path string) (pkg *Object, err error)
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
// be used as dependencies by other rules.
|
||||
//
|
||||
// DO NOT CHANGE THIS DATA TO FIX BUILDS.
|
||||
//
|
||||
//
|
||||
var pkgDeps = map[string][]string{
|
||||
// L0 is the lowest level, core, nearly unavoidable packages.
|
||||
"errors": {},
|
||||
|
@ -23,12 +23,12 @@
|
||||
// As in the Go tree, each target operating system and
|
||||
// architecture pair has its own subdirectory of pkg
|
||||
// (pkg/GOOS_GOARCH).
|
||||
//
|
||||
//
|
||||
// If DIR is a directory listed in the Go path, a package with
|
||||
// source in DIR/src/foo/bar can be imported as "foo/bar" and
|
||||
// has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a"
|
||||
// (or, for gccgo, "DIR/pkg/gccgo/foo/libbar.a").
|
||||
//
|
||||
//
|
||||
// The bin/ directory holds compiled commands.
|
||||
// Each command is named for its source directory, but only
|
||||
// using the final element, not the entire path. That is, the
|
||||
@ -36,11 +36,11 @@
|
||||
// DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped
|
||||
// so that you can add DIR/bin to your PATH to get at the
|
||||
// installed commands.
|
||||
//
|
||||
//
|
||||
// Here's an example directory layout:
|
||||
//
|
||||
//
|
||||
// GOPATH=/home/user/gocode
|
||||
//
|
||||
//
|
||||
// /home/user/gocode/
|
||||
// src/
|
||||
// foo/
|
||||
|
@ -174,7 +174,7 @@ func unindent(block []string) {
|
||||
}
|
||||
|
||||
// heading returns the trimmed line if it passes as a section heading;
|
||||
// otherwise it returns the empty string.
|
||||
// otherwise it returns the empty string.
|
||||
func heading(line string) string {
|
||||
line = strings.TrimSpace(line)
|
||||
if len(line) == 0 {
|
||||
|
@ -119,7 +119,7 @@ func playExample(file *ast.File, body *ast.BlockStmt) *ast.File {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Find unresolved identifiers
|
||||
// Find unresolved identifiers
|
||||
unresolved := make(map[string]bool)
|
||||
ast.Inspect(body, func(n ast.Node) bool {
|
||||
// For an expression like fmt.Println, only add "fmt" to the
|
||||
@ -243,7 +243,7 @@ func playExampleFile(file *ast.File) *ast.File {
|
||||
return &f
|
||||
}
|
||||
|
||||
// stripOutputComment finds and removes an "Output:" commment from body
|
||||
// stripOutputComment finds and removes an "Output:" commment from body
|
||||
// and comments, and adjusts the body block's end position.
|
||||
func stripOutputComment(body *ast.BlockStmt, comments []*ast.CommentGroup) (*ast.BlockStmt, []*ast.CommentGroup) {
|
||||
// Do nothing if no "Output:" comment found.
|
||||
|
@ -107,7 +107,7 @@ func (r *reader) filterParamList(fields *ast.FieldList) {
|
||||
|
||||
// filterType strips any unexported struct fields or method types from typ
|
||||
// in place. If fields (or methods) have been removed, the corresponding
|
||||
// struct or interface type has the Incomplete field set to true.
|
||||
// struct or interface type has the Incomplete field set to true.
|
||||
//
|
||||
func (r *reader) filterType(parent *namedType, typ ast.Expr) {
|
||||
switch t := typ.(type) {
|
||||
|
@ -46,7 +46,7 @@ func (mset methodSet) set(f *ast.FuncDecl) {
|
||||
// since it has documentation, assume f is simply another
|
||||
// implementation and ignore it. This does not happen if the
|
||||
// caller is using go/build.ScanDir to determine the list of
|
||||
// files implementing a package.
|
||||
// files implementing a package.
|
||||
return
|
||||
}
|
||||
// function doesn't exist or has no documentation; use f
|
||||
@ -597,7 +597,7 @@ func (r *reader) computeMethodSets() {
|
||||
// types that have no declaration. Instead, these functions and methods
|
||||
// are shown at the package level. It also removes types with missing
|
||||
// declarations or which are not visible.
|
||||
//
|
||||
//
|
||||
func (r *reader) cleanupTypes() {
|
||||
for _, t := range r.types {
|
||||
visible := r.isVisible(t.name)
|
||||
|
2
src/pkg/go/doc/testdata/e.go
vendored
2
src/pkg/go/doc/testdata/e.go
vendored
@ -106,7 +106,7 @@ type U4 struct {
|
||||
*u5
|
||||
}
|
||||
|
||||
// U4.M should appear as method of U4.
|
||||
// U4.M should appear as method of U4.
|
||||
func (*U4) M() {}
|
||||
|
||||
type u5 struct {
|
||||
|
4
src/pkg/go/doc/testdata/testing.go
vendored
4
src/pkg/go/doc/testdata/testing.go
vendored
@ -197,7 +197,7 @@ func (c *common) Fatalf(format string, args ...interface{}) {
|
||||
c.FailNow()
|
||||
}
|
||||
|
||||
// Parallel signals that this test is to be run in parallel with (and only with)
|
||||
// Parallel signals that this test is to be run in parallel with (and only with)
|
||||
// other parallel tests in this CPU group.
|
||||
func (t *T) Parallel() {
|
||||
t.signal <- (*T)(nil) // Release main testing loop
|
||||
@ -215,7 +215,7 @@ func tRunner(t *T, test *InternalTest) {
|
||||
t.start = time.Now()
|
||||
|
||||
// When this goroutine is done, either because test.F(t)
|
||||
// returned normally or because a test failure triggered
|
||||
// returned normally or because a test failure triggered
|
||||
// a call to runtime.Goexit, record the duration and send
|
||||
// a signal saying that the test is done.
|
||||
defer func() {
|
||||
|
@ -158,7 +158,7 @@ func ParseDir(fset *token.FileSet, path string, filter func(os.FileInfo) bool, m
|
||||
|
||||
// ParseExpr is a convenience function for obtaining the AST of an expression x.
|
||||
// The position information recorded in the AST is undefined.
|
||||
//
|
||||
//
|
||||
func ParseExpr(x string) (ast.Expr, error) {
|
||||
// parse x within the context of a complete package for correct scopes;
|
||||
// use //line directive for correct positions in error messages and put
|
||||
|
@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This file implements a simple printer performance benchmark:
|
||||
// go test -bench=BenchmarkPrint
|
||||
// go test -bench=BenchmarkPrint
|
||||
|
||||
package printer
|
||||
|
||||
|
@ -76,7 +76,7 @@ type Pos int
|
||||
// associated with it, and NoPos().IsValid() is false. NoPos is always
|
||||
// smaller than any other Pos value. The corresponding Position value
|
||||
// for NoPos is the zero value for Position.
|
||||
//
|
||||
//
|
||||
const NoPos Pos = 0
|
||||
|
||||
// IsValid returns true if the position is valid.
|
||||
@ -347,7 +347,7 @@ func (s *FileSet) AddFile(filename string, base, size int) *File {
|
||||
|
||||
// Iterate calls f for the files in the file set in the order they were added
|
||||
// until f returns false.
|
||||
//
|
||||
//
|
||||
func (s *FileSet) Iterate(f func(*File) bool) {
|
||||
for i := 0; ; i++ {
|
||||
var file *File
|
||||
|
@ -15,7 +15,7 @@ type writer interface {
|
||||
WriteString(string) (int, error)
|
||||
}
|
||||
|
||||
// These replacements permit compatibility with old numeric entities that
|
||||
// These replacements permit compatibility with old numeric entities that
|
||||
// assumed Windows-1252 encoding.
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#consume-a-character-reference
|
||||
var replacementTable = [...]rune{
|
||||
@ -51,7 +51,7 @@ var replacementTable = [...]rune{
|
||||
'\u009D',
|
||||
'\u017E',
|
||||
'\u0178', // Last entry is 0x9F.
|
||||
// 0x00->'\uFFFD' is handled programmatically.
|
||||
// 0x00->'\uFFFD' is handled programmatically.
|
||||
// 0x0D->'\u000D' is a no-op.
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ type (
|
||||
HTMLAttr string
|
||||
|
||||
// JS encapsulates a known safe EcmaScript5 Expression, for example,
|
||||
// `(x + y * z())`.
|
||||
// `(x + y * z())`.
|
||||
// Template authors are responsible for ensuring that typed expressions
|
||||
// do not break the intended precedence and that there is no
|
||||
// statement/expression ambiguity as when passing an expression like
|
||||
|
@ -102,7 +102,7 @@ const (
|
||||
//
|
||||
// {{define "main"}} <script>{{template "helper"}}</script> {{end}}
|
||||
// {{define "helper"}} document.write(' <div title=" ') {{end}}
|
||||
//
|
||||
//
|
||||
// "helper" does not produce a valid document fragment, so should
|
||||
// not be Executed directly.
|
||||
ErrEndContext
|
||||
@ -161,7 +161,7 @@ const (
|
||||
// In the example, there is missing a quote, so it is not clear
|
||||
// whether {{.}} is meant to be inside a JS string or in a JS value
|
||||
// context. The second iteration would produce something like
|
||||
//
|
||||
//
|
||||
// <script>var x = ['firstValue,'secondValue]</script>
|
||||
ErrRangeLoopReentry
|
||||
|
||||
|
@ -106,7 +106,7 @@ var htmlNospaceReplacementTable = []string{
|
||||
'<': "<",
|
||||
'=': "=",
|
||||
'>': ">",
|
||||
// A parse error in the attribute value (unquoted) and
|
||||
// A parse error in the attribute value (unquoted) and
|
||||
// before attribute value states.
|
||||
// Treated as a quoting character by IE.
|
||||
'`': "`",
|
||||
@ -128,7 +128,7 @@ var htmlNospaceNormReplacementTable = []string{
|
||||
'<': "<",
|
||||
'=': "=",
|
||||
'>': ">",
|
||||
// A parse error in the attribute value (unquoted) and
|
||||
// A parse error in the attribute value (unquoted) and
|
||||
// before attribute value states.
|
||||
// Treated as a quoting character by IE.
|
||||
'`': "`",
|
||||
@ -143,7 +143,7 @@ func htmlReplacer(s string, replacementTable []string, badRunes bool) string {
|
||||
if repl := replacementTable[r]; len(repl) != 0 {
|
||||
b.WriteString(s[written:i])
|
||||
b.WriteString(repl)
|
||||
// Valid as long as replacementTable doesn't
|
||||
// Valid as long as replacementTable doesn't
|
||||
// include anything above 0x7f.
|
||||
written = i + utf8.RuneLen(r)
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ func (x *Int) Format(s fmt.State, ch rune) {
|
||||
if precisionSet {
|
||||
switch {
|
||||
case len(digits) < precision:
|
||||
zeroes = precision - len(digits) // count of zero padding
|
||||
zeroes = precision - len(digits) // count of zero padding
|
||||
case digits == "0" && precision == 0:
|
||||
return // print nothing if zero value (x == 0) and zero precision ("." or ".0")
|
||||
}
|
||||
|
@ -421,17 +421,17 @@ func (z nat) mul(x, y nat) nat {
|
||||
z[2*k:].clear() // upper portion of z is garbage (and 2*k <= m+n since k <= n <= m)
|
||||
|
||||
// If xh != 0 or yh != 0, add the missing terms to z. For
|
||||
//
|
||||
// xh = xi*b^i + ... + x2*b^2 + x1*b (0 <= xi < b)
|
||||
// yh = y1*b (0 <= y1 < b)
|
||||
//
|
||||
// the missing terms are
|
||||
//
|
||||
// x0*y1*b and xi*y0*b^i, xi*y1*b^(i+1) for i > 0
|
||||
//
|
||||
// since all the yi for i > 1 are 0 by choice of k: If any of them
|
||||
// were > 0, then yh >= b^2 and thus y >= b^2. Then k' = k*2 would
|
||||
// be a larger valid threshold contradicting the assumption about k.
|
||||
//
|
||||
// xh = xi*b^i + ... + x2*b^2 + x1*b (0 <= xi < b)
|
||||
// yh = y1*b (0 <= y1 < b)
|
||||
//
|
||||
// the missing terms are
|
||||
//
|
||||
// x0*y1*b and xi*y0*b^i, xi*y1*b^(i+1) for i > 0
|
||||
//
|
||||
// since all the yi for i > 1 are 0 by choice of k: If any of them
|
||||
// were > 0, then yh >= b^2 and thus y >= b^2. Then k' = k*2 would
|
||||
// be a larger valid threshold contradicting the assumption about k.
|
||||
//
|
||||
if k < n || m != n {
|
||||
var t nat
|
||||
@ -828,16 +828,16 @@ func (x nat) string(charset string) string {
|
||||
// by nat/nat division using tabulated divisors. Otherwise, it is converted iteratively using
|
||||
// repeated nat/Word divison.
|
||||
//
|
||||
// The iterative method processes n Words by n divW() calls, each of which visits every Word in the
|
||||
// incrementally shortened q for a total of n + (n-1) + (n-2) ... + 2 + 1, or n(n+1)/2 divW()'s.
|
||||
// Recursive conversion divides q by its approximate square root, yielding two parts, each half
|
||||
// The iterative method processes n Words by n divW() calls, each of which visits every Word in the
|
||||
// incrementally shortened q for a total of n + (n-1) + (n-2) ... + 2 + 1, or n(n+1)/2 divW()'s.
|
||||
// Recursive conversion divides q by its approximate square root, yielding two parts, each half
|
||||
// the size of q. Using the iterative method on both halves means 2 * (n/2)(n/2 + 1)/2 divW()'s
|
||||
// plus the expensive long div(). Asymptotically, the ratio is favorable at 1/2 the divW()'s, and
|
||||
// is made better by splitting the subblocks recursively. Best is to split blocks until one more
|
||||
// split would take longer (because of the nat/nat div()) than the twice as many divW()'s of the
|
||||
// iterative approach. This threshold is represented by leafSize. Benchmarking of leafSize in the
|
||||
// range 2..64 shows that values of 8 and 16 work well, with a 4x speedup at medium lengths and
|
||||
// ~30x for 20000 digits. Use nat_test.go's BenchmarkLeafSize tests to optimize leafSize for
|
||||
// is made better by splitting the subblocks recursively. Best is to split blocks until one more
|
||||
// split would take longer (because of the nat/nat div()) than the twice as many divW()'s of the
|
||||
// iterative approach. This threshold is represented by leafSize. Benchmarking of leafSize in the
|
||||
// range 2..64 shows that values of 8 and 16 work well, with a 4x speedup at medium lengths and
|
||||
// ~30x for 20000 digits. Use nat_test.go's BenchmarkLeafSize tests to optimize leafSize for
|
||||
// specific hardware.
|
||||
//
|
||||
func (q nat) convertWords(s []byte, charset string, b Word, ndigits int, bb Word, table []divisor) {
|
||||
|
@ -166,7 +166,7 @@ func TestMulRangeN(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// allocBytes returns the number of bytes allocated by invoking f.
|
||||
// allocBytes returns the number of bytes allocated by invoking f.
|
||||
func allocBytes(f func()) uint64 {
|
||||
var stats runtime.MemStats
|
||||
runtime.ReadMemStats(&stats)
|
||||
@ -546,7 +546,7 @@ func BenchmarkLeafSize13(b *testing.B) { LeafSizeHelper(b, 10, 13) }
|
||||
func BenchmarkLeafSize14(b *testing.B) { LeafSizeHelper(b, 10, 14) }
|
||||
func BenchmarkLeafSize15(b *testing.B) { LeafSizeHelper(b, 10, 15) }
|
||||
func BenchmarkLeafSize16(b *testing.B) { LeafSizeHelper(b, 10, 16) }
|
||||
func BenchmarkLeafSize32(b *testing.B) { LeafSizeHelper(b, 10, 32) } // try some large lengths
|
||||
func BenchmarkLeafSize32(b *testing.B) { LeafSizeHelper(b, 10, 32) } // try some large lengths
|
||||
func BenchmarkLeafSize64(b *testing.B) { LeafSizeHelper(b, 10, 64) }
|
||||
|
||||
func LeafSizeHelper(b *testing.B, base Word, size int) {
|
||||
|
@ -55,7 +55,7 @@ func TestDialTimeout(t *testing.T) {
|
||||
// on our 386 builder, this Dial succeeds, connecting
|
||||
// to an IIS web server somewhere. The data center
|
||||
// or VM or firewall must be stealing the TCP connection.
|
||||
//
|
||||
//
|
||||
// IANA Service Name and Transport Protocol Port Number Registry
|
||||
// <http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml>
|
||||
go func() {
|
||||
|
@ -183,7 +183,7 @@ func (s byPriorityWeight) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
// shuffleByWeight shuffles SRV records by weight using the algorithm
|
||||
// described in RFC 2782.
|
||||
// described in RFC 2782.
|
||||
func (addrs byPriorityWeight) shuffleByWeight() {
|
||||
sum := 0
|
||||
for _, addr := range addrs {
|
||||
|
@ -17,7 +17,7 @@ func ExampleListener() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for {
|
||||
// Wait for a connection.
|
||||
// Wait for a connection.
|
||||
conn, err := l.Accept()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Issue 3590. netFd.AddFD should return an error
|
||||
// Issue 3590. netFd.AddFD should return an error
|
||||
// from the underlying pollster rather than panicing.
|
||||
func TestAddFDReturnsError(t *testing.T) {
|
||||
l, err := Listen("tcp", "127.0.0.1:0")
|
||||
|
@ -22,7 +22,7 @@ const maxLineLength = 4096 // assumed <= bufio.defaultBufSize
|
||||
var ErrLineTooLong = errors.New("header line too long")
|
||||
|
||||
// newChunkedReader returns a new chunkedReader that translates the data read from r
|
||||
// out of HTTP "chunked" format before returning it.
|
||||
// out of HTTP "chunked" format before returning it.
|
||||
// The chunkedReader returns io.EOF when the final 0-length chunk is read.
|
||||
//
|
||||
// newChunkedReader is not needed by normal applications. The http package
|
||||
|
@ -26,7 +26,7 @@ type Cookie struct {
|
||||
Expires time.Time
|
||||
RawExpires string
|
||||
|
||||
// MaxAge=0 means no 'Max-Age' attribute specified.
|
||||
// MaxAge=0 means no 'Max-Age' attribute specified.
|
||||
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
|
||||
// MaxAge>0 means Max-Age attribute present and given in seconds
|
||||
MaxAge int
|
||||
|
@ -217,7 +217,7 @@ var readCookiesTests = []struct {
|
||||
|
||||
func TestReadCookies(t *testing.T) {
|
||||
for i, tt := range readCookiesTests {
|
||||
for n := 0; n < 2; n++ { // to verify readCookies doesn't mutate its input
|
||||
for n := 0; n < 2; n++ { // to verify readCookies doesn't mutate its input
|
||||
c := readCookies(tt.Header, tt.Filter)
|
||||
if !reflect.DeepEqual(c, tt.Cookies) {
|
||||
t.Errorf("#%d readCookies:\nhave: %s\nwant: %s\n", i, toJSON(c), toJSON(tt.Cookies))
|
||||
|
@ -24,7 +24,7 @@ const maxLineLength = 4096 // assumed <= bufio.defaultBufSize
|
||||
var ErrLineTooLong = errors.New("header line too long")
|
||||
|
||||
// NewChunkedReader returns a new chunkedReader that translates the data read from r
|
||||
// out of HTTP "chunked" format before returning it.
|
||||
// out of HTTP "chunked" format before returning it.
|
||||
// The chunkedReader returns io.EOF when the final 0-length chunk is read.
|
||||
//
|
||||
// NewChunkedReader is not needed by normal applications. The http package
|
||||
|
@ -25,7 +25,7 @@ var UseProxyTests = []struct {
|
||||
{"[::2]", true}, // not a loopback address
|
||||
|
||||
{"barbaz.net", false}, // match as .barbaz.net
|
||||
{"foobar.com", false}, // have a port but match
|
||||
{"foobar.com", false}, // have a port but match
|
||||
{"foofoobar.com", true}, // not match as a part of foobar.com
|
||||
{"baz.com", true}, // not match as a part of barbaz.com
|
||||
{"localhost.net", true}, // not match as suffix of address
|
||||
|
@ -161,7 +161,7 @@ func TestSetBasicAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMultipartRequest(t *testing.T) {
|
||||
// Test that we can read the values and files of a
|
||||
// Test that we can read the values and files of a
|
||||
// multipart request with FormValue and FormFile,
|
||||
// and that ParseMultipartForm can be called multiple times.
|
||||
req := newTestMultipartRequest(t)
|
||||
|
@ -314,7 +314,7 @@ func TestServerTimeouts(t *testing.T) {
|
||||
l.Close()
|
||||
}
|
||||
|
||||
// TestIdentityResponse verifies that a handler can unset
|
||||
// TestIdentityResponse verifies that a handler can unset
|
||||
func TestIdentityResponse(t *testing.T) {
|
||||
handler := HandlerFunc(func(rw ResponseWriter, req *Request) {
|
||||
rw.Header().Set("Content-Length", "3")
|
||||
|
@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// HTTP client implementation. See RFC 2616.
|
||||
//
|
||||
//
|
||||
// This is the low-level Transport implementation of RoundTripper.
|
||||
// The high-level interface is in client.go.
|
||||
|
||||
@ -707,7 +707,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
|
||||
// requested it.
|
||||
requestedGzip := false
|
||||
if !pc.t.DisableCompression && req.Header.Get("Accept-Encoding") == "" {
|
||||
// Request gzip only, not deflate. Deflate is ambiguous and
|
||||
// Request gzip only, not deflate. Deflate is ambiguous and
|
||||
// not as universally supported anyway.
|
||||
// See: http://www.gzip.org/zlib/zlib_faq.html#faq38
|
||||
requestedGzip = true
|
||||
|
@ -228,7 +228,7 @@ func DialHTTP(network, address string) (*Client, error) {
|
||||
return DialHTTPPath(network, address, DefaultRPCPath)
|
||||
}
|
||||
|
||||
// DialHTTPPath connects to an HTTP RPC server
|
||||
// DialHTTPPath connects to an HTTP RPC server
|
||||
// at the specified network address and path.
|
||||
func DialHTTPPath(network, address, path string) (*Client, error) {
|
||||
var err error
|
||||
|
@ -227,7 +227,7 @@ func (server *Server) Register(rcvr interface{}) error {
|
||||
return server.register(rcvr, "", false)
|
||||
}
|
||||
|
||||
// RegisterName is like Register but uses the provided name for the type
|
||||
// RegisterName is like Register but uses the provided name for the type
|
||||
// instead of the receiver's concrete type.
|
||||
func (server *Server) RegisterName(name string, rcvr interface{}) error {
|
||||
return server.register(rcvr, name, true)
|
||||
@ -569,7 +569,7 @@ func (server *Server) Accept(lis net.Listener) {
|
||||
// Register publishes the receiver's methods in the DefaultServer.
|
||||
func Register(rcvr interface{}) error { return DefaultServer.Register(rcvr) }
|
||||
|
||||
// RegisterName is like Register but uses the provided name for the type
|
||||
// RegisterName is like Register but uses the provided name for the type
|
||||
// instead of the receiver's concrete type.
|
||||
func RegisterName(name string, rcvr interface{}) error {
|
||||
return DefaultServer.RegisterName(name, rcvr)
|
||||
@ -612,7 +612,7 @@ func ServeRequest(codec ServerCodec) error {
|
||||
}
|
||||
|
||||
// Accept accepts connections on the listener and serves requests
|
||||
// to DefaultServer for each incoming connection.
|
||||
// to DefaultServer for each incoming connection.
|
||||
// Accept blocks; the caller typically invokes it in a go statement.
|
||||
func Accept(lis net.Listener) { DefaultServer.Accept(lis) }
|
||||
|
||||
|
@ -171,9 +171,9 @@ var dualStackListenerTests = []struct {
|
||||
// Test cases and expected results for the attemping 2nd listen on the same port
|
||||
// 1st listen 2nd listen darwin freebsd linux openbsd
|
||||
// ------------------------------------------------------------------------------------
|
||||
// "tcp" "" "tcp" "" - - - -
|
||||
// "tcp" "" "tcp" "0.0.0.0" - - - -
|
||||
// "tcp" "0.0.0.0" "tcp" "" - - - -
|
||||
// "tcp" "" "tcp" "" - - - -
|
||||
// "tcp" "" "tcp" "0.0.0.0" - - - -
|
||||
// "tcp" "0.0.0.0" "tcp" "" - - - -
|
||||
// ------------------------------------------------------------------------------------
|
||||
// "tcp" "" "tcp" "[::]" - - - ok
|
||||
// "tcp" "[::]" "tcp" "" - - - ok
|
||||
|
@ -163,7 +163,7 @@ func (client *expClient) run() {
|
||||
// all messages <=N have been seen by the recipient. We check anyway.
|
||||
expLog("sequence out of order:", client.ackNum, hdr.SeqNum)
|
||||
}
|
||||
if client.ackNum < hdr.SeqNum { // If there has been an error, don't back up the count.
|
||||
if client.ackNum < hdr.SeqNum { // If there has been an error, don't back up the count.
|
||||
client.ackNum = hdr.SeqNum
|
||||
}
|
||||
client.mu.Unlock()
|
||||
|
@ -110,7 +110,7 @@ var nullDir = dir{
|
||||
}
|
||||
|
||||
// Null assigns members of d with special "don't care" values indicating
|
||||
// they should not be written by syscall.Wstat.
|
||||
// they should not be written by syscall.Wstat.
|
||||
func (d *dir) Null() {
|
||||
*d = nullDir
|
||||
}
|
||||
@ -118,7 +118,7 @@ func (d *dir) Null() {
|
||||
// pdir appends a 9P Stat message based on the contents of Dir d to a byte slice b.
|
||||
func pdir(b []byte, d *dir) []byte {
|
||||
n := len(b)
|
||||
b = pbit16(b, 0) // length, filled in later
|
||||
b = pbit16(b, 0) // length, filled in later
|
||||
b = pbit16(b, d.Type)
|
||||
b = pbit32(b, d.Dev)
|
||||
b = pqid(b, d.Qid)
|
||||
|
@ -43,7 +43,7 @@ func NewSyscallError(syscall string, err error) error {
|
||||
return &SyscallError{syscall, err}
|
||||
}
|
||||
|
||||
// IsExist returns whether the error is known to report that a file or directory
|
||||
// IsExist returns whether the error is known to report that a file or directory
|
||||
// already exists. It is satisfied by ErrExist as well as some syscall errors.
|
||||
func IsExist(err error) bool {
|
||||
return isExist(err)
|
||||
|
@ -37,7 +37,7 @@ type Cmd struct {
|
||||
|
||||
// Args holds command line arguments, including the command as Args[0].
|
||||
// If the Args field is empty or nil, Run uses {Path}.
|
||||
//
|
||||
//
|
||||
// In typical use, both Path and Args are set by calling Command.
|
||||
Args []string
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user