package testdata

import (
	"go/token"
	"os"
)

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)
}
