本文整理汇总了Golang中llvm/org/llgo/third_party/gotools/go/loader.Config.AllowErrors方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.AllowErrors方法的具体用法?Golang Config.AllowErrors怎么用?Golang Config.AllowErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm/org/llgo/third_party/gotools/go/loader.Config
的用法示例。
在下文中一共展示了Config.AllowErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLoad_ParseError_AllowErrors
func TestLoad_ParseError_AllowErrors(t *testing.T) {
var conf loader.Config
conf.AllowErrors = true
conf.CreateFromFilenames("badpkg", "testdata/badpkgdecl.go")
prog, err := conf.Load()
if err != nil {
t.Errorf("Load failed unexpectedly: %v", err)
}
if prog == nil {
t.Fatalf("Load returned a nil Program")
}
if got, want := created(prog), "badpkg"; got != want {
t.Errorf("Created = %s, want %s", got, want)
}
badpkg := prog.Created[0]
if len(badpkg.Files) != 1 {
t.Errorf("badpkg has %d files, want 1", len(badpkg.Files))
}
wantErr := "testdata/badpkgdecl.go:1:34: expected 'package', found 'EOF'"
if !hasError(badpkg.Errors, wantErr) {
t.Errorf("badpkg.Errors = %v, want %s", badpkg.Errors, wantErr)
}
}
示例2: TestLoad_MissingInitialPackage_AllowErrors
func TestLoad_MissingInitialPackage_AllowErrors(t *testing.T) {
var conf loader.Config
conf.AllowErrors = true
conf.Import("nosuchpkg")
conf.ImportWithTests("errors")
prog, err := conf.Load()
if err != nil {
t.Errorf("Load failed unexpectedly: %v", err)
}
if prog == nil {
t.Fatalf("Load returned a nil Program")
}
if got, want := created(prog), "errors_test"; got != want {
t.Errorf("Created = %s, want %s", got, want)
}
if got, want := imported(prog), "errors"; got != want {
t.Errorf("Imported = %s, want %s", got, want)
}
}