-
Notifications
You must be signed in to change notification settings - Fork 546
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 #409 from xushiwei/e
testdata
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 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
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 @@ | ||
package testdata | ||
|
||
import ( | ||
"os" | ||
"go/token" | ||
) | ||
|
||
var stmtStart = map[token.Token]bool{ | ||
token.BREAK: true, | ||
token.CONST: true, | ||
token.CONTINUE: true, | ||
token.DEFER: true, | ||
token.FALLTHROUGH: true, | ||
token.FOR: true, | ||
token.GO: true, | ||
token.GOTO: true, | ||
token.IF: true, | ||
token.RETURN: true, | ||
token.SELECT: true, | ||
token.SWITCH: true, | ||
token.TYPE: true, | ||
token.VAR: true, | ||
} | ||
|
||
type Mode uint | ||
|
||
const ( | ||
// PackageClauseOnly - stop parsing after package clause | ||
PackageClauseOnly Mode = 1 << iota | ||
// ImportsOnly - stop parsing after import declarations | ||
ImportsOnly | ||
// ParseComments - parse comments and add them to AST | ||
ParseComments | ||
// Trace - print a trace of parsed productions | ||
Trace | ||
// DeclarationErrors - report declaration errors | ||
DeclarationErrors | ||
// AllErrors - report all errors (not just the first 10 on different lines) | ||
AllErrors | ||
) | ||
|
||
// FileSystem represents a file system. | ||
type FileSystem interface { | ||
ReadDir(dirname string) ([]os.FileInfo, error) | ||
ReadFile(filename string) ([]byte, error) | ||
Join(elem ...string) string | ||
} | ||
|
||
type IF = FileSystem | ||
|
||
type Foo struct { | ||
a, b map[string]struct{} | ||
} | ||
|
||
func (p *Foo) bar() { | ||
} | ||
|
||
func init() { | ||
f, err := os.Open("a") | ||
if err != nil { | ||
return | ||
} | ||
defer f.Close() | ||
|
||
ch := make(chan bool, 100) | ||
select { | ||
case <-ch: | ||
println("1") | ||
case ch <- true: | ||
println("2") | ||
} | ||
|
||
go func(fs FileSystem) { | ||
if foo, ok := fs.(*Foo); ok { | ||
println(foo) | ||
} | ||
}(nil) | ||
} |