This repository has been archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from hensur/re-extract-2020-10-08
re-extract 2020-10-08
- Loading branch information
Showing
116 changed files
with
9,430 additions
and
6,668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Package cfg holds configuration shared by the Go command and internal/testenv. | ||
// Definitions that don't need to be exposed outside of cmd/go should be in | ||
// cmd/go/internal/cfg instead of this package. | ||
package cfg | ||
|
||
// KnownEnv is a list of environment variables that affect the operation | ||
// of the Go command. | ||
const KnownEnv = ` | ||
AR | ||
CC | ||
CGO_CFLAGS | ||
CGO_CFLAGS_ALLOW | ||
CGO_CFLAGS_DISALLOW | ||
CGO_CPPFLAGS | ||
CGO_CPPFLAGS_ALLOW | ||
CGO_CPPFLAGS_DISALLOW | ||
CGO_CXXFLAGS | ||
CGO_CXXFLAGS_ALLOW | ||
CGO_CXXFLAGS_DISALLOW | ||
CGO_ENABLED | ||
CGO_FFLAGS | ||
CGO_FFLAGS_ALLOW | ||
CGO_FFLAGS_DISALLOW | ||
CGO_LDFLAGS | ||
CGO_LDFLAGS_ALLOW | ||
CGO_LDFLAGS_DISALLOW | ||
CXX | ||
FC | ||
GCCGO | ||
GO111MODULE | ||
GO386 | ||
GOARCH | ||
GOARM | ||
GOBIN | ||
GOCACHE | ||
GOENV | ||
GOEXE | ||
GOFLAGS | ||
GOGCCFLAGS | ||
GOHOSTARCH | ||
GOHOSTOS | ||
GOINSECURE | ||
GOMIPS | ||
GOMIPS64 | ||
GOMODCACHE | ||
GONOPROXY | ||
GONOSUMDB | ||
GOOS | ||
GOPATH | ||
GOPPC64 | ||
GOPRIVATE | ||
GOPROXY | ||
GOROOT | ||
GOSUMDB | ||
GOTMPDIR | ||
GOTOOLDIR | ||
GOWASM | ||
GO_EXTLINK_ENABLED | ||
PKG_CONFIG | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Package lazyregexp is a thin wrapper over regexp, allowing the use of global | ||
// regexp variables without forcing them to be compiled at init. | ||
package lazyregexp | ||
|
||
import ( | ||
"os" | ||
"regexp" | ||
"strings" | ||
"sync" | ||
) | ||
|
||
// Regexp is a wrapper around regexp.Regexp, where the underlying regexp will be | ||
// compiled the first time it is needed. | ||
type Regexp struct { | ||
str string | ||
once sync.Once | ||
rx *regexp.Regexp | ||
} | ||
|
||
func (r *Regexp) re() *regexp.Regexp { | ||
r.once.Do(r.build) | ||
return r.rx | ||
} | ||
|
||
func (r *Regexp) build() { | ||
r.rx = regexp.MustCompile(r.str) | ||
r.str = "" | ||
} | ||
|
||
func (r *Regexp) FindSubmatch(s []byte) [][]byte { | ||
return r.re().FindSubmatch(s) | ||
} | ||
|
||
func (r *Regexp) FindStringSubmatch(s string) []string { | ||
return r.re().FindStringSubmatch(s) | ||
} | ||
|
||
func (r *Regexp) FindStringSubmatchIndex(s string) []int { | ||
return r.re().FindStringSubmatchIndex(s) | ||
} | ||
|
||
func (r *Regexp) ReplaceAllString(src, repl string) string { | ||
return r.re().ReplaceAllString(src, repl) | ||
} | ||
|
||
func (r *Regexp) FindString(s string) string { | ||
return r.re().FindString(s) | ||
} | ||
|
||
func (r *Regexp) FindAllString(s string, n int) []string { | ||
return r.re().FindAllString(s, n) | ||
} | ||
|
||
func (r *Regexp) MatchString(s string) bool { | ||
return r.re().MatchString(s) | ||
} | ||
|
||
func (r *Regexp) SubexpNames() []string { | ||
return r.re().SubexpNames() | ||
} | ||
|
||
var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") | ||
|
||
// New creates a new lazy regexp, delaying the compiling work until it is first | ||
// needed. If the code is being run as part of tests, the regexp compiling will | ||
// happen immediately. | ||
func New(str string) *Regexp { | ||
lr := &Regexp{str: str} | ||
if inTest { | ||
// In tests, always compile the regexps early. | ||
lr.re() | ||
} | ||
return lr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Package lazytemplate is a thin wrapper over text/template, allowing the use | ||
// of global template variables without forcing them to be parsed at init. | ||
package lazytemplate | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"strings" | ||
"sync" | ||
"text/template" | ||
) | ||
|
||
// Template is a wrapper around text/template.Template, where the underlying | ||
// template will be parsed the first time it is needed. | ||
type Template struct { | ||
name, text string | ||
|
||
once sync.Once | ||
tmpl *template.Template | ||
} | ||
|
||
func (r *Template) tp() *template.Template { | ||
r.once.Do(r.build) | ||
return r.tmpl | ||
} | ||
|
||
func (r *Template) build() { | ||
r.tmpl = template.Must(template.New(r.name).Parse(r.text)) | ||
r.name, r.text = "", "" | ||
} | ||
|
||
func (r *Template) Execute(w io.Writer, data interface{}) error { | ||
return r.tp().Execute(w, data) | ||
} | ||
|
||
var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") | ||
|
||
// New creates a new lazy template, delaying the parsing work until it is first | ||
// needed. If the code is being run as part of tests, the template parsing will | ||
// happen immediately. | ||
func New(name, text string) *Template { | ||
lt := &Template{name: name, text: text} | ||
if inTest { | ||
// In tests, always parse the templates early. | ||
lt.tp() | ||
} | ||
return lt | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.