update revive lint to latest commit (#12921)
* update revive lint to latest commit * make fmt * change importmj-v1.14.3
parent
63e8bdaf73
commit
1c3278c2fa
@ -1,8 +1,16 @@
|
|||||||
language: go
|
language: go
|
||||||
|
sudo: false
|
||||||
go:
|
go:
|
||||||
|
- 1.13.x
|
||||||
- tip
|
- tip
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- go get github.com/mattn/goveralls
|
- go get -t -v ./...
|
||||||
- go get golang.org/x/tools/cmd/cover
|
|
||||||
script:
|
script:
|
||||||
- $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL
|
- go generate
|
||||||
|
- git diff --cached --exit-code
|
||||||
|
- ./go.test.sh
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
echo "" > coverage.txt
|
||||||
|
|
||||||
|
for d in $(go list ./... | grep -v vendor); do
|
||||||
|
go test -race -coverprofile=profile.out -covermode=atomic "$d"
|
||||||
|
if [ -f profile.out ]; then
|
||||||
|
cat profile.out >> coverage.txt
|
||||||
|
rm profile.out
|
||||||
|
fi
|
||||||
|
done
|
@ -0,0 +1,137 @@
|
|||||||
|
package rule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go/ast"
|
||||||
|
|
||||||
|
"github.com/mgechev/revive/lint"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeferRule lints unused params in functions.
|
||||||
|
type DeferRule struct{}
|
||||||
|
|
||||||
|
// Apply applies the rule to given file.
|
||||||
|
func (r *DeferRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
||||||
|
allow := r.allowFromArgs(arguments)
|
||||||
|
|
||||||
|
var failures []lint.Failure
|
||||||
|
onFailure := func(failure lint.Failure) {
|
||||||
|
failures = append(failures, failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
w := lintDeferRule{onFailure: onFailure, allow: allow}
|
||||||
|
|
||||||
|
ast.Walk(w, file.AST)
|
||||||
|
|
||||||
|
return failures
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the rule name.
|
||||||
|
func (r *DeferRule) Name() string {
|
||||||
|
return "defer"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *DeferRule) allowFromArgs(args lint.Arguments) map[string]bool {
|
||||||
|
if len(args) < 1 {
|
||||||
|
allow := map[string]bool{
|
||||||
|
"loop": true,
|
||||||
|
"call-chain": true,
|
||||||
|
"method-call": true,
|
||||||
|
"return": true,
|
||||||
|
"recover": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return allow
|
||||||
|
}
|
||||||
|
|
||||||
|
aa, ok := args[0].([]interface{})
|
||||||
|
if !ok {
|
||||||
|
panic(fmt.Sprintf("Invalid argument '%v' for 'defer' rule. Expecting []string, got %T", args[0], args[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
allow := make(map[string]bool, len(aa))
|
||||||
|
for _, subcase := range aa {
|
||||||
|
sc, ok := subcase.(string)
|
||||||
|
if !ok {
|
||||||
|
panic(fmt.Sprintf("Invalid argument '%v' for 'defer' rule. Expecting string, got %T", subcase, subcase))
|
||||||
|
}
|
||||||
|
allow[sc] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return allow
|
||||||
|
}
|
||||||
|
|
||||||
|
type lintDeferRule struct {
|
||||||
|
onFailure func(lint.Failure)
|
||||||
|
inALoop bool
|
||||||
|
inADefer bool
|
||||||
|
inAFuncLit bool
|
||||||
|
allow map[string]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w lintDeferRule) Visit(node ast.Node) ast.Visitor {
|
||||||
|
switch n := node.(type) {
|
||||||
|
case *ast.ForStmt:
|
||||||
|
w.visitSubtree(n.Body, w.inADefer, true, w.inAFuncLit)
|
||||||
|
return nil
|
||||||
|
case *ast.RangeStmt:
|
||||||
|
w.visitSubtree(n.Body, w.inADefer, true, w.inAFuncLit)
|
||||||
|
return nil
|
||||||
|
case *ast.FuncLit:
|
||||||
|
w.visitSubtree(n.Body, w.inADefer, false, true)
|
||||||
|
return nil
|
||||||
|
case *ast.ReturnStmt:
|
||||||
|
if len(n.Results) != 0 && w.inADefer && w.inAFuncLit {
|
||||||
|
w.newFailure("return in a defer function has no effect", n, 1.0, "logic", "return")
|
||||||
|
}
|
||||||
|
case *ast.CallExpr:
|
||||||
|
if isIdent(n.Fun, "recover") && !w.inADefer {
|
||||||
|
// confidence is not 1 because recover can be in a function that is deferred elsewhere
|
||||||
|
w.newFailure("recover must be called inside a deferred function", n, 0.8, "logic", "recover")
|
||||||
|
}
|
||||||
|
case *ast.DeferStmt:
|
||||||
|
w.visitSubtree(n.Call.Fun, true, false, false)
|
||||||
|
|
||||||
|
if w.inALoop {
|
||||||
|
w.newFailure("prefer not to defer inside loops", n, 1.0, "bad practice", "loop")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch fn := n.Call.Fun.(type) {
|
||||||
|
case *ast.CallExpr:
|
||||||
|
w.newFailure("prefer not to defer chains of function calls", fn, 1.0, "bad practice", "call-chain")
|
||||||
|
case *ast.SelectorExpr:
|
||||||
|
if id, ok := fn.X.(*ast.Ident); ok {
|
||||||
|
isMethodCall := id != nil && id.Obj != nil && id.Obj.Kind == ast.Typ
|
||||||
|
if isMethodCall {
|
||||||
|
w.newFailure("be careful when deferring calls to methods without pointer receiver", fn, 0.8, "bad practice", "method-call")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w lintDeferRule) visitSubtree(n ast.Node, inADefer, inALoop, inAFuncLit bool) {
|
||||||
|
nw := &lintDeferRule{
|
||||||
|
onFailure: w.onFailure,
|
||||||
|
inADefer: inADefer,
|
||||||
|
inALoop: inALoop,
|
||||||
|
inAFuncLit: inAFuncLit,
|
||||||
|
allow: w.allow}
|
||||||
|
ast.Walk(nw, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w lintDeferRule) newFailure(msg string, node ast.Node, confidence float64, cat string, subcase string) {
|
||||||
|
if !w.allow[subcase] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.onFailure(lint.Failure{
|
||||||
|
Confidence: confidence,
|
||||||
|
Node: node,
|
||||||
|
Category: cat,
|
||||||
|
Failure: msg,
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package rule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go/ast"
|
||||||
|
|
||||||
|
"github.com/mgechev/revive/lint"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EarlyReturnRule lints given else constructs.
|
||||||
|
type EarlyReturnRule struct{}
|
||||||
|
|
||||||
|
// Apply applies the rule to given file.
|
||||||
|
func (r *EarlyReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||||
|
var failures []lint.Failure
|
||||||
|
|
||||||
|
onFailure := func(failure lint.Failure) {
|
||||||
|
failures = append(failures, failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
w := lintEarlyReturnRule{onFailure: onFailure}
|
||||||
|
ast.Walk(w, file.AST)
|
||||||
|
return failures
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the rule name.
|
||||||
|
func (r *EarlyReturnRule) Name() string {
|
||||||
|
return "early-return"
|
||||||
|
}
|
||||||
|
|
||||||
|
type lintEarlyReturnRule struct {
|
||||||
|
onFailure func(lint.Failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w lintEarlyReturnRule) Visit(node ast.Node) ast.Visitor {
|
||||||
|
switch n := node.(type) {
|
||||||
|
case *ast.IfStmt:
|
||||||
|
if n.Else == nil {
|
||||||
|
// no else branch
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
elseBlock, ok := n.Else.(*ast.BlockStmt)
|
||||||
|
if !ok {
|
||||||
|
// is if-else-if
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
lenElseBlock := len(elseBlock.List)
|
||||||
|
if lenElseBlock < 1 {
|
||||||
|
// empty else block, continue (there is another rule that warns on empty blocks)
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
lenThenBlock := len(n.Body.List)
|
||||||
|
if lenThenBlock < 1 {
|
||||||
|
// then block is empty thus the stmt can be simplified
|
||||||
|
w.onFailure(lint.Failure{
|
||||||
|
Confidence: 1,
|
||||||
|
Node: n,
|
||||||
|
Failure: "if c { } else {... return} can be simplified to if !c { ... return }",
|
||||||
|
})
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
_, lastThenStmtIsReturn := n.Body.List[lenThenBlock-1].(*ast.ReturnStmt)
|
||||||
|
_, lastElseStmtIsReturn := elseBlock.List[lenElseBlock-1].(*ast.ReturnStmt)
|
||||||
|
if lastElseStmtIsReturn && !lastThenStmtIsReturn {
|
||||||
|
w.onFailure(lint.Failure{
|
||||||
|
Confidence: 1,
|
||||||
|
Node: n,
|
||||||
|
Failure: "if c {...} else {... return } can be simplified to if !c { ... return } ...",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package rule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go/ast"
|
||||||
|
|
||||||
|
"github.com/mgechev/revive/lint"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IdenticalBranchesRule warns on constant logical expressions.
|
||||||
|
type IdenticalBranchesRule struct{}
|
||||||
|
|
||||||
|
// Apply applies the rule to given file.
|
||||||
|
func (r *IdenticalBranchesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||||
|
var failures []lint.Failure
|
||||||
|
|
||||||
|
onFailure := func(failure lint.Failure) {
|
||||||
|
failures = append(failures, failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
astFile := file.AST
|
||||||
|
w := &lintIdenticalBranches{astFile, onFailure}
|
||||||
|
ast.Walk(w, astFile)
|
||||||
|
return failures
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the rule name.
|
||||||
|
func (r *IdenticalBranchesRule) Name() string {
|
||||||
|
return "identical-branches"
|
||||||
|
}
|
||||||
|
|
||||||
|
type lintIdenticalBranches struct {
|
||||||
|
file *ast.File
|
||||||
|
onFailure func(lint.Failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *lintIdenticalBranches) Visit(node ast.Node) ast.Visitor {
|
||||||
|
n, ok := node.(*ast.IfStmt)
|
||||||
|
if !ok {
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.Else == nil {
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
branches := []*ast.BlockStmt{n.Body}
|
||||||
|
|
||||||
|
elseBranch, ok := n.Else.(*ast.BlockStmt)
|
||||||
|
if !ok { // if-else-if construction
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
branches = append(branches, elseBranch)
|
||||||
|
|
||||||
|
if w.identicalBranches(branches) {
|
||||||
|
w.newFailure(n, "both branches of the if are identical")
|
||||||
|
}
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *lintIdenticalBranches) identicalBranches(branches []*ast.BlockStmt) bool {
|
||||||
|
if len(branches) < 2 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
ref := gofmt(branches[0])
|
||||||
|
for i := 1; i < len(branches); i++ {
|
||||||
|
if gofmt(branches[i]) != ref {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w lintIdenticalBranches) newFailure(node ast.Node, msg string) {
|
||||||
|
w.onFailure(lint.Failure{
|
||||||
|
Confidence: 1,
|
||||||
|
Node: node,
|
||||||
|
Category: "logic",
|
||||||
|
Failure: msg,
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,183 @@
|
|||||||
|
package rule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go/ast"
|
||||||
|
|
||||||
|
"github.com/mgechev/revive/lint"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UnconditionalRecursionRule lints given else constructs.
|
||||||
|
type UnconditionalRecursionRule struct{}
|
||||||
|
|
||||||
|
// Apply applies the rule to given file.
|
||||||
|
func (r *UnconditionalRecursionRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||||
|
var failures []lint.Failure
|
||||||
|
|
||||||
|
onFailure := func(failure lint.Failure) {
|
||||||
|
failures = append(failures, failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
w := lintUnconditionalRecursionRule{onFailure: onFailure}
|
||||||
|
ast.Walk(w, file.AST)
|
||||||
|
return failures
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the rule name.
|
||||||
|
func (r *UnconditionalRecursionRule) Name() string {
|
||||||
|
return "unconditional-recursion"
|
||||||
|
}
|
||||||
|
|
||||||
|
type funcDesc struct {
|
||||||
|
reciverID *ast.Ident
|
||||||
|
id *ast.Ident
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fd *funcDesc) equal(other *funcDesc) bool {
|
||||||
|
receiversAreEqual := (fd.reciverID == nil && other.reciverID == nil) || fd.reciverID != nil && other.reciverID != nil && fd.reciverID.Name == other.reciverID.Name
|
||||||
|
idsAreEqual := (fd.id == nil && other.id == nil) || fd.id.Name == other.id.Name
|
||||||
|
|
||||||
|
return receiversAreEqual && idsAreEqual
|
||||||
|
}
|
||||||
|
|
||||||
|
type funcStatus struct {
|
||||||
|
funcDesc *funcDesc
|
||||||
|
seenConditionalExit bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type lintUnconditionalRecursionRule struct {
|
||||||
|
onFailure func(lint.Failure)
|
||||||
|
currentFunc *funcStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit will traverse the file AST.
|
||||||
|
// The rule is based in the following algorithm: inside each function body we search for calls to the function itself.
|
||||||
|
// We do not search inside conditional control structures (if, for, switch, ...) because any recursive call inside them is conditioned
|
||||||
|
// We do search inside conditional control structures are statements that will take the control out of the function (return, exit, panic)
|
||||||
|
// If we find conditional control exits, it means the function is NOT unconditionally-recursive
|
||||||
|
// If we find a recursive call before finding any conditional exit, a failure is generated
|
||||||
|
// In resume: if we found a recursive call control-dependant from the entry point of the function then we raise a failure.
|
||||||
|
func (w lintUnconditionalRecursionRule) Visit(node ast.Node) ast.Visitor {
|
||||||
|
switch n := node.(type) {
|
||||||
|
case *ast.FuncDecl:
|
||||||
|
var rec *ast.Ident
|
||||||
|
switch {
|
||||||
|
case n.Recv == nil || n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1:
|
||||||
|
rec = nil
|
||||||
|
default:
|
||||||
|
rec = n.Recv.List[0].Names[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
w.currentFunc = &funcStatus{&funcDesc{rec, n.Name}, false}
|
||||||
|
case *ast.CallExpr:
|
||||||
|
var funcID *ast.Ident
|
||||||
|
var selector *ast.Ident
|
||||||
|
switch c := n.Fun.(type) {
|
||||||
|
case *ast.Ident:
|
||||||
|
selector = nil
|
||||||
|
funcID = c
|
||||||
|
case *ast.SelectorExpr:
|
||||||
|
var ok bool
|
||||||
|
selector, ok = c.X.(*ast.Ident)
|
||||||
|
if !ok { // a.b....Foo()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
funcID = c.Sel
|
||||||
|
default:
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
if w.currentFunc != nil && // not in a func body
|
||||||
|
!w.currentFunc.seenConditionalExit && // there is a conditional exit in the function
|
||||||
|
w.currentFunc.funcDesc.equal(&funcDesc{selector, funcID}) {
|
||||||
|
w.onFailure(lint.Failure{
|
||||||
|
Category: "logic",
|
||||||
|
Confidence: 1,
|
||||||
|
Node: n,
|
||||||
|
Failure: "unconditional recursive call",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case *ast.IfStmt:
|
||||||
|
w.updateFuncStatus(n.Body)
|
||||||
|
w.updateFuncStatus(n.Else)
|
||||||
|
return nil
|
||||||
|
case *ast.SelectStmt:
|
||||||
|
w.updateFuncStatus(n.Body)
|
||||||
|
return nil
|
||||||
|
case *ast.RangeStmt:
|
||||||
|
w.updateFuncStatus(n.Body)
|
||||||
|
return nil
|
||||||
|
case *ast.TypeSwitchStmt:
|
||||||
|
w.updateFuncStatus(n.Body)
|
||||||
|
return nil
|
||||||
|
case *ast.SwitchStmt:
|
||||||
|
w.updateFuncStatus(n.Body)
|
||||||
|
return nil
|
||||||
|
case *ast.GoStmt:
|
||||||
|
for _, a := range n.Call.Args {
|
||||||
|
ast.Walk(w, a) // check if arguments have a recursive call
|
||||||
|
}
|
||||||
|
return nil // recursive async call is not an issue
|
||||||
|
case *ast.ForStmt:
|
||||||
|
if n.Cond != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// unconditional loop
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *lintUnconditionalRecursionRule) updateFuncStatus(node ast.Node) {
|
||||||
|
if node == nil || w.currentFunc == nil || w.currentFunc.seenConditionalExit {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.currentFunc.seenConditionalExit = w.hasControlExit(node)
|
||||||
|
}
|
||||||
|
|
||||||
|
var exitFunctions = map[string]map[string]bool{
|
||||||
|
"os": map[string]bool{"Exit": true},
|
||||||
|
"syscall": map[string]bool{"Exit": true},
|
||||||
|
"log": map[string]bool{
|
||||||
|
"Fatal": true,
|
||||||
|
"Fatalf": true,
|
||||||
|
"Fatalln": true,
|
||||||
|
"Panic": true,
|
||||||
|
"Panicf": true,
|
||||||
|
"Panicln": true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *lintUnconditionalRecursionRule) hasControlExit(node ast.Node) bool {
|
||||||
|
// isExit returns true if the given node makes control exit the function
|
||||||
|
isExit := func(node ast.Node) bool {
|
||||||
|
switch n := node.(type) {
|
||||||
|
case *ast.ReturnStmt:
|
||||||
|
return true
|
||||||
|
case *ast.CallExpr:
|
||||||
|
if isIdent(n.Fun, "panic") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
se, ok := n.Fun.(*ast.SelectorExpr)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
id, ok := se.X.(*ast.Ident)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn := se.Sel.Name
|
||||||
|
pkg := id.Name
|
||||||
|
if exitFunctions[pkg] != nil && exitFunctions[pkg][fn] { // it's a call to an exit function
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(pick(node, isExit, nil)) != 0
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
package rule
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go/ast"
|
||||||
|
"go/token"
|
||||||
|
|
||||||
|
"github.com/mgechev/revive/lint"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UnexportedNamingRule lints wrongly named unexported symbols.
|
||||||
|
type UnexportedNamingRule struct{}
|
||||||
|
|
||||||
|
// Apply applies the rule to given file.
|
||||||
|
func (r *UnexportedNamingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
|
||||||
|
var failures []lint.Failure
|
||||||
|
onFailure := func(failure lint.Failure) {
|
||||||
|
failures = append(failures, failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
ba := &unexportablenamingLinter{onFailure}
|
||||||
|
ast.Walk(ba, file.AST)
|
||||||
|
|
||||||
|
return failures
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the rule name.
|
||||||
|
func (r *UnexportedNamingRule) Name() string {
|
||||||
|
return "unexported-naming"
|
||||||
|
}
|
||||||
|
|
||||||
|
type unexportablenamingLinter struct {
|
||||||
|
onFailure func(lint.Failure)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (unl unexportablenamingLinter) Visit(node ast.Node) ast.Visitor {
|
||||||
|
switch n := node.(type) {
|
||||||
|
case *ast.FuncDecl:
|
||||||
|
unl.lintFunction(n.Type, n.Body)
|
||||||
|
return nil
|
||||||
|
case *ast.FuncLit:
|
||||||
|
unl.lintFunction(n.Type, n.Body)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
case *ast.AssignStmt:
|
||||||
|
if n.Tok != token.DEFINE {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ids := []*ast.Ident{}
|
||||||
|
for _, e := range n.Lhs {
|
||||||
|
id, ok := e.(*ast.Ident)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
unl.lintIDs(ids)
|
||||||
|
|
||||||
|
case *ast.DeclStmt:
|
||||||
|
gd, ok := n.Decl.(*ast.GenDecl)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(gd.Specs) < 1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
vs, ok := gd.Specs[0].(*ast.ValueSpec)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
unl.lintIDs(vs.Names)
|
||||||
|
}
|
||||||
|
|
||||||
|
return unl
|
||||||
|
}
|
||||||
|
|
||||||
|
func (unl unexportablenamingLinter) lintFunction(ft *ast.FuncType, body *ast.BlockStmt) {
|
||||||
|
unl.lintFields(ft.Params)
|
||||||
|
unl.lintFields(ft.Results)
|
||||||
|
|
||||||
|
if body != nil {
|
||||||
|
ast.Walk(unl, body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (unl unexportablenamingLinter) lintFields(fields *ast.FieldList) {
|
||||||
|
if fields == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ids := []*ast.Ident{}
|
||||||
|
for _, field := range fields.List {
|
||||||
|
ids = append(ids, field.Names...)
|
||||||
|
}
|
||||||
|
|
||||||
|
unl.lintIDs(ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (unl unexportablenamingLinter) lintIDs(ids []*ast.Ident) {
|
||||||
|
for _, id := range ids {
|
||||||
|
if id.IsExported() {
|
||||||
|
unl.onFailure(lint.Failure{
|
||||||
|
Node: id,
|
||||||
|
Confidence: 1,
|
||||||
|
Category: "naming",
|
||||||
|
Failure: fmt.Sprintf("the symbol %s is local, its name should start with a lowercase letter", id.String()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,164 +0,0 @@
|
|||||||
{
|
|
||||||
"array": {
|
|
||||||
"key1": [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3
|
|
||||||
],
|
|
||||||
"key2": [
|
|
||||||
"red",
|
|
||||||
"yellow",
|
|
||||||
"green"
|
|
||||||
],
|
|
||||||
"key3": [
|
|
||||||
[
|
|
||||||
1,
|
|
||||||
2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"key4": [
|
|
||||||
[
|
|
||||||
1,
|
|
||||||
2
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"a",
|
|
||||||
"b",
|
|
||||||
"c"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"key5": [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3
|
|
||||||
],
|
|
||||||
"key6": [
|
|
||||||
1,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"boolean": {
|
|
||||||
"False": false,
|
|
||||||
"True": true
|
|
||||||
},
|
|
||||||
"datetime": {
|
|
||||||
"key1": "1979-05-27T07:32:00Z",
|
|
||||||
"key2": "1979-05-27T00:32:00-07:00",
|
|
||||||
"key3": "1979-05-27T00:32:00.999999-07:00"
|
|
||||||
},
|
|
||||||
"float": {
|
|
||||||
"both": {
|
|
||||||
"key": 6.626e-34
|
|
||||||
},
|
|
||||||
"exponent": {
|
|
||||||
"key1": 5e+22,
|
|
||||||
"key2": 1000000,
|
|
||||||
"key3": -0.02
|
|
||||||
},
|
|
||||||
"fractional": {
|
|
||||||
"key1": 1,
|
|
||||||
"key2": 3.1415,
|
|
||||||
"key3": -0.01
|
|
||||||
},
|
|
||||||
"underscores": {
|
|
||||||
"key1": 9224617.445991227,
|
|
||||||
"key2": 1e+100
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fruit": [{
|
|
||||||
"name": "apple",
|
|
||||||
"physical": {
|
|
||||||
"color": "red",
|
|
||||||
"shape": "round"
|
|
||||||
},
|
|
||||||
"variety": [{
|
|
||||||
"name": "red delicious"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "granny smith"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "banana",
|
|
||||||
"variety": [{
|
|
||||||
"name": "plantain"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"integer": {
|
|
||||||
"key1": 99,
|
|
||||||
"key2": 42,
|
|
||||||
"key3": 0,
|
|
||||||
"key4": -17,
|
|
||||||
"underscores": {
|
|
||||||
"key1": 1000,
|
|
||||||
"key2": 5349221,
|
|
||||||
"key3": 12345
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"products": [{
|
|
||||||
"name": "Hammer",
|
|
||||||
"sku": 738594937
|
|
||||||
},
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
"color": "gray",
|
|
||||||
"name": "Nail",
|
|
||||||
"sku": 284758393
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"string": {
|
|
||||||
"basic": {
|
|
||||||
"basic": "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."
|
|
||||||
},
|
|
||||||
"literal": {
|
|
||||||
"multiline": {
|
|
||||||
"lines": "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n",
|
|
||||||
"regex2": "I [dw]on't need \\d{2} apples"
|
|
||||||
},
|
|
||||||
"quoted": "Tom \"Dubs\" Preston-Werner",
|
|
||||||
"regex": "\u003c\\i\\c*\\s*\u003e",
|
|
||||||
"winpath": "C:\\Users\\nodejs\\templates",
|
|
||||||
"winpath2": "\\\\ServerX\\admin$\\system32\\"
|
|
||||||
},
|
|
||||||
"multiline": {
|
|
||||||
"continued": {
|
|
||||||
"key1": "The quick brown fox jumps over the lazy dog.",
|
|
||||||
"key2": "The quick brown fox jumps over the lazy dog.",
|
|
||||||
"key3": "The quick brown fox jumps over the lazy dog."
|
|
||||||
},
|
|
||||||
"key1": "One\nTwo",
|
|
||||||
"key2": "One\nTwo",
|
|
||||||
"key3": "One\nTwo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"table": {
|
|
||||||
"inline": {
|
|
||||||
"name": {
|
|
||||||
"first": "Tom",
|
|
||||||
"last": "Preston-Werner"
|
|
||||||
},
|
|
||||||
"point": {
|
|
||||||
"x": 1,
|
|
||||||
"y": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"key": "value",
|
|
||||||
"subtable": {
|
|
||||||
"key": "another value"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"x": {
|
|
||||||
"y": {
|
|
||||||
"z": {
|
|
||||||
"w": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,244 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
## Comment
|
|
||||||
|
|
||||||
# Speak your mind with the hash symbol. They go from the symbol to the end of
|
|
||||||
# the line.
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Table
|
|
||||||
|
|
||||||
# Tables (also known as hash tables or dictionaries) are collections of
|
|
||||||
# key/value pairs. They appear in square brackets on a line by themselves.
|
|
||||||
|
|
||||||
[table]
|
|
||||||
|
|
||||||
key = "value" # Yeah, you can do this.
|
|
||||||
|
|
||||||
# Nested tables are denoted by table names with dots in them. Name your tables
|
|
||||||
# whatever crap you please, just don't use #, ., [ or ].
|
|
||||||
|
|
||||||
[table.subtable]
|
|
||||||
|
|
||||||
key = "another value"
|
|
||||||
|
|
||||||
# You don't need to specify all the super-tables if you don't want to. TOML
|
|
||||||
# knows how to do it for you.
|
|
||||||
|
|
||||||
# [x] you
|
|
||||||
# [x.y] don't
|
|
||||||
# [x.y.z] need these
|
|
||||||
[x.y.z.w] # for this to work
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Inline Table
|
|
||||||
|
|
||||||
# Inline tables provide a more compact syntax for expressing tables. They are
|
|
||||||
# especially useful for grouped data that can otherwise quickly become verbose.
|
|
||||||
# Inline tables are enclosed in curly braces `{` and `}`. No newlines are
|
|
||||||
# allowed between the curly braces unless they are valid within a value.
|
|
||||||
|
|
||||||
[table.inline]
|
|
||||||
|
|
||||||
name = { first = "Tom", last = "Preston-Werner" }
|
|
||||||
point = { x = 1, y = 2 }
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## String
|
|
||||||
|
|
||||||
# There are four ways to express strings: basic, multi-line basic, literal, and
|
|
||||||
# multi-line literal. All strings must contain only valid UTF-8 characters.
|
|
||||||
|
|
||||||
[string.basic]
|
|
||||||
|
|
||||||
basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
|
||||||
|
|
||||||
[string.multiline]
|
|
||||||
|
|
||||||
# The following strings are byte-for-byte equivalent:
|
|
||||||
key1 = "One\nTwo"
|
|
||||||
key2 = """One\nTwo"""
|
|
||||||
key3 = """
|
|
||||||
One
|
|
||||||
Two"""
|
|
||||||
|
|
||||||
[string.multiline.continued]
|
|
||||||
|
|
||||||
# The following strings are byte-for-byte equivalent:
|
|
||||||
key1 = "The quick brown fox jumps over the lazy dog."
|
|
||||||
|
|
||||||
key2 = """
|
|
||||||
The quick brown \
|
|
||||||
|
|
||||||
|
|
||||||
fox jumps over \
|
|
||||||
the lazy dog."""
|
|
||||||
|
|
||||||
key3 = """\
|
|
||||||
The quick brown \
|
|
||||||
fox jumps over \
|
|
||||||
the lazy dog.\
|
|
||||||
"""
|
|
||||||
|
|
||||||
[string.literal]
|
|
||||||
|
|
||||||
# What you see is what you get.
|
|
||||||
winpath = 'C:\Users\nodejs\templates'
|
|
||||||
winpath2 = '\\ServerX\admin$\system32\'
|
|
||||||
quoted = 'Tom "Dubs" Preston-Werner'
|
|
||||||
regex = '<\i\c*\s*>'
|
|
||||||
|
|
||||||
|
|
||||||
[string.literal.multiline]
|
|
||||||
|
|
||||||
regex2 = '''I [dw]on't need \d{2} apples'''
|
|
||||||
lines = '''
|
|
||||||
The first newline is
|
|
||||||
trimmed in raw strings.
|
|
||||||
All other whitespace
|
|
||||||
is preserved.
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Integer
|
|
||||||
|
|
||||||
# Integers are whole numbers. Positive numbers may be prefixed with a plus sign.
|
|
||||||
# Negative numbers are prefixed with a minus sign.
|
|
||||||
|
|
||||||
[integer]
|
|
||||||
|
|
||||||
key1 = +99
|
|
||||||
key2 = 42
|
|
||||||
key3 = 0
|
|
||||||
key4 = -17
|
|
||||||
|
|
||||||
[integer.underscores]
|
|
||||||
|
|
||||||
# For large numbers, you may use underscores to enhance readability. Each
|
|
||||||
# underscore must be surrounded by at least one digit.
|
|
||||||
key1 = 1_000
|
|
||||||
key2 = 5_349_221
|
|
||||||
key3 = 1_2_3_4_5 # valid but inadvisable
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Float
|
|
||||||
|
|
||||||
# A float consists of an integer part (which may be prefixed with a plus or
|
|
||||||
# minus sign) followed by a fractional part and/or an exponent part.
|
|
||||||
|
|
||||||
[float.fractional]
|
|
||||||
|
|
||||||
key1 = +1.0
|
|
||||||
key2 = 3.1415
|
|
||||||
key3 = -0.01
|
|
||||||
|
|
||||||
[float.exponent]
|
|
||||||
|
|
||||||
key1 = 5e+22
|
|
||||||
key2 = 1e6
|
|
||||||
key3 = -2E-2
|
|
||||||
|
|
||||||
[float.both]
|
|
||||||
|
|
||||||
key = 6.626e-34
|
|
||||||
|
|
||||||
[float.underscores]
|
|
||||||
|
|
||||||
key1 = 9_224_617.445_991_228_313
|
|
||||||
key2 = 1e1_00
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Boolean
|
|
||||||
|
|
||||||
# Booleans are just the tokens you're used to. Always lowercase.
|
|
||||||
|
|
||||||
[boolean]
|
|
||||||
|
|
||||||
True = true
|
|
||||||
False = false
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Datetime
|
|
||||||
|
|
||||||
# Datetimes are RFC 3339 dates.
|
|
||||||
|
|
||||||
[datetime]
|
|
||||||
|
|
||||||
key1 = 1979-05-27T07:32:00Z
|
|
||||||
key2 = 1979-05-27T00:32:00-07:00
|
|
||||||
key3 = 1979-05-27T00:32:00.999999-07:00
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Array
|
|
||||||
|
|
||||||
# Arrays are square brackets with other primitives inside. Whitespace is
|
|
||||||
# ignored. Elements are separated by commas. Data types may not be mixed.
|
|
||||||
|
|
||||||
[array]
|
|
||||||
|
|
||||||
key1 = [ 1, 2, 3 ]
|
|
||||||
key2 = [ "red", "yellow", "green" ]
|
|
||||||
key3 = [ [ 1, 2 ], [3, 4, 5] ]
|
|
||||||
#key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok
|
|
||||||
|
|
||||||
# Arrays can also be multiline. So in addition to ignoring whitespace, arrays
|
|
||||||
# also ignore newlines between the brackets. Terminating commas are ok before
|
|
||||||
# the closing bracket.
|
|
||||||
|
|
||||||
key5 = [
|
|
||||||
1, 2, 3
|
|
||||||
]
|
|
||||||
key6 = [
|
|
||||||
1,
|
|
||||||
2, # this is ok
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Array of Tables
|
|
||||||
|
|
||||||
# These can be expressed by using a table name in double brackets. Each table
|
|
||||||
# with the same double bracketed name will be an element in the array. The
|
|
||||||
# tables are inserted in the order encountered.
|
|
||||||
|
|
||||||
[[products]]
|
|
||||||
|
|
||||||
name = "Hammer"
|
|
||||||
sku = 738594937
|
|
||||||
|
|
||||||
[[products]]
|
|
||||||
|
|
||||||
[[products]]
|
|
||||||
|
|
||||||
name = "Nail"
|
|
||||||
sku = 284758393
|
|
||||||
color = "gray"
|
|
||||||
|
|
||||||
|
|
||||||
# You can create nested arrays of tables as well.
|
|
||||||
|
|
||||||
[[fruit]]
|
|
||||||
name = "apple"
|
|
||||||
|
|
||||||
[fruit.physical]
|
|
||||||
color = "red"
|
|
||||||
shape = "round"
|
|
||||||
|
|
||||||
[[fruit.variety]]
|
|
||||||
name = "red delicious"
|
|
||||||
|
|
||||||
[[fruit.variety]]
|
|
||||||
name = "granny smith"
|
|
||||||
|
|
||||||
[[fruit]]
|
|
||||||
name = "banana"
|
|
||||||
|
|
||||||
[[fruit.variety]]
|
|
||||||
name = "plantain"
|
|
@ -1,121 +0,0 @@
|
|||||||
---
|
|
||||||
array:
|
|
||||||
key1:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
key2:
|
|
||||||
- red
|
|
||||||
- yellow
|
|
||||||
- green
|
|
||||||
key3:
|
|
||||||
- - 1
|
|
||||||
- 2
|
|
||||||
- - 3
|
|
||||||
- 4
|
|
||||||
- 5
|
|
||||||
key4:
|
|
||||||
- - 1
|
|
||||||
- 2
|
|
||||||
- - a
|
|
||||||
- b
|
|
||||||
- c
|
|
||||||
key5:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
key6:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
boolean:
|
|
||||||
'False': false
|
|
||||||
'True': true
|
|
||||||
datetime:
|
|
||||||
key1: '1979-05-27T07:32:00Z'
|
|
||||||
key2: '1979-05-27T00:32:00-07:00'
|
|
||||||
key3: '1979-05-27T00:32:00.999999-07:00'
|
|
||||||
float:
|
|
||||||
both:
|
|
||||||
key: 6.626e-34
|
|
||||||
exponent:
|
|
||||||
key1: 5.0e+22
|
|
||||||
key2: 1000000
|
|
||||||
key3: -0.02
|
|
||||||
fractional:
|
|
||||||
key1: 1
|
|
||||||
key2: 3.1415
|
|
||||||
key3: -0.01
|
|
||||||
underscores:
|
|
||||||
key1: 9224617.445991227
|
|
||||||
key2: 1.0e+100
|
|
||||||
fruit:
|
|
||||||
- name: apple
|
|
||||||
physical:
|
|
||||||
color: red
|
|
||||||
shape: round
|
|
||||||
variety:
|
|
||||||
- name: red delicious
|
|
||||||
- name: granny smith
|
|
||||||
- name: banana
|
|
||||||
variety:
|
|
||||||
- name: plantain
|
|
||||||
integer:
|
|
||||||
key1: 99
|
|
||||||
key2: 42
|
|
||||||
key3: 0
|
|
||||||
key4: -17
|
|
||||||
underscores:
|
|
||||||
key1: 1000
|
|
||||||
key2: 5349221
|
|
||||||
key3: 12345
|
|
||||||
products:
|
|
||||||
- name: Hammer
|
|
||||||
sku: 738594937
|
|
||||||
- {}
|
|
||||||
- color: gray
|
|
||||||
name: Nail
|
|
||||||
sku: 284758393
|
|
||||||
string:
|
|
||||||
basic:
|
|
||||||
basic: "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."
|
|
||||||
literal:
|
|
||||||
multiline:
|
|
||||||
lines: |
|
|
||||||
The first newline is
|
|
||||||
trimmed in raw strings.
|
|
||||||
All other whitespace
|
|
||||||
is preserved.
|
|
||||||
regex2: I [dw]on't need \d{2} apples
|
|
||||||
quoted: Tom "Dubs" Preston-Werner
|
|
||||||
regex: "<\\i\\c*\\s*>"
|
|
||||||
winpath: C:\Users\nodejs\templates
|
|
||||||
winpath2: "\\\\ServerX\\admin$\\system32\\"
|
|
||||||
multiline:
|
|
||||||
continued:
|
|
||||||
key1: The quick brown fox jumps over the lazy dog.
|
|
||||||
key2: The quick brown fox jumps over the lazy dog.
|
|
||||||
key3: The quick brown fox jumps over the lazy dog.
|
|
||||||
key1: |-
|
|
||||||
One
|
|
||||||
Two
|
|
||||||
key2: |-
|
|
||||||
One
|
|
||||||
Two
|
|
||||||
key3: |-
|
|
||||||
One
|
|
||||||
Two
|
|
||||||
table:
|
|
||||||
inline:
|
|
||||||
name:
|
|
||||||
first: Tom
|
|
||||||
last: Preston-Werner
|
|
||||||
point:
|
|
||||||
x: 1
|
|
||||||
y: 2
|
|
||||||
key: value
|
|
||||||
subtable:
|
|
||||||
key: another value
|
|
||||||
x:
|
|
||||||
y:
|
|
||||||
z:
|
|
||||||
w: {}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
// +build !linux,arm
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func archInit() {}
|
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
// +build ppc64 ppc64le
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 128
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "darn", Feature: &PPC64.HasDARN},
|
||||||
|
{Name: "scv", Feature: &PPC64.HasSCV},
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2020 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 cpu
|
||||||
|
|
||||||
|
const cacheLineSize = 256
|
||||||
|
|
||||||
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "zarch", Feature: &S390X.HasZARCH},
|
||||||
|
{Name: "stfle", Feature: &S390X.HasSTFLE},
|
||||||
|
{Name: "ldisp", Feature: &S390X.HasLDISP},
|
||||||
|
{Name: "eimm", Feature: &S390X.HasEIMM},
|
||||||
|
{Name: "dfp", Feature: &S390X.HasDFP},
|
||||||
|
{Name: "etf3eh", Feature: &S390X.HasETF3EH},
|
||||||
|
{Name: "msa", Feature: &S390X.HasMSA},
|
||||||
|
{Name: "aes", Feature: &S390X.HasAES},
|
||||||
|
{Name: "aescbc", Feature: &S390X.HasAESCBC},
|
||||||
|
{Name: "aesctr", Feature: &S390X.HasAESCTR},
|
||||||
|
{Name: "aesgcm", Feature: &S390X.HasAESGCM},
|
||||||
|
{Name: "ghash", Feature: &S390X.HasGHASH},
|
||||||
|
{Name: "sha1", Feature: &S390X.HasSHA1},
|
||||||
|
{Name: "sha256", Feature: &S390X.HasSHA256},
|
||||||
|
{Name: "sha3", Feature: &S390X.HasSHA3},
|
||||||
|
{Name: "sha512", Feature: &S390X.HasSHA512},
|
||||||
|
{Name: "vx", Feature: &S390X.HasVX},
|
||||||
|
{Name: "vxe", Feature: &S390X.HasVXE},
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for mips64, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
@ -1,9 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
// +build darwin,386,!go1.12
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
|
@ -1,9 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
// +build darwin,amd64,!go1.12
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
|
@ -1,11 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
// +build darwin,arm,!go1.12
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
|
||||||
return 0, ENOSYS
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
// +build darwin,arm64,!go1.12
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
|
||||||
return 0, ENOSYS
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
// +build arm,!gccgo,linux
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
// Underlying system call writes to newoffset via pointer.
|
||||||
|
// Implemented in assembly to avoid allocation.
|
||||||
|
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
|
@ -0,0 +1,35 @@
|
|||||||
|
// 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 unix
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: sec, Usec: usec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of OpenBSD the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue