本文整理匯總了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)
}
}