Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for ReadImports (0.27 sec)

  1. src/cmd/go/internal/imports/read_test.go

    	},
    }
    
    func TestReadFailures(t *testing.T) {
    	// Errors should be reported (true arg to readImports).
    	testRead(t, readFailuresTests, func(r io.Reader) ([]byte, error) { return ReadImports(r, true, nil) })
    }
    
    func TestReadFailuresIgnored(t *testing.T) {
    	// Syntax errors should not be reported (false arg to readImports).
    	// Instead, entire file should be the output and no error.
    	// Convert tests not to return syntax errors.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 15 18:42:11 UTC 2021
    - 4.2K bytes
    - Viewed (0)
  2. src/cmd/go/internal/imports/read.go

    		// Didn't reach EOF, so must have found a non-space byte. Remove it.
    		r.buf = r.buf[:len(r.buf)-1]
    	}
    	return r.buf, r.err
    }
    
    // ReadImports is like io.ReadAll, except that it expects a Go file as input
    // and stops reading the input once the imports have completed.
    func ReadImports(f io.Reader, reportSyntaxError bool, imports *[]string) ([]byte, error) {
    	r := newImportReader(bufio.NewReader(f))
    
    	r.readKeyword("package")
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 15 18:42:11 UTC 2021
    - 6.1K bytes
    - Viewed (0)
  3. src/cmd/dist/imports.go

    	if r.err == nil && !r.eof {
    		// Didn't reach EOF, so must have found a non-space byte. Remove it.
    		r.buf = r.buf[:len(r.buf)-1]
    	}
    	return r.buf, r.err
    }
    
    // readimports returns the imports found in the named file.
    func readimports(file string) []string {
    	var imports []string
    	r := &importReader{b: bufio.NewReader(strings.NewReader(readfile(file)))}
    	r.readKeyword("package")
    	r.readIdent()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 28 21:45:30 UTC 2019
    - 6.3K bytes
    - Viewed (0)
  4. src/cmd/go/internal/imports/scan.go

    	testImports := make(map[string]bool)
    	numFiles := 0
    Files:
    	for _, name := range files {
    		r, err := fsys.Open(name)
    		if err != nil {
    			return nil, nil, err
    		}
    		var list []string
    		data, err := ReadImports(r, false, &list)
    		r.Close()
    		if err != nil {
    			return nil, nil, fmt.Errorf("reading %s: %v", name, err)
    		}
    
    		// import "C" is implicit requirement of cgo tag.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 23 19:36:38 UTC 2020
    - 2.6K bytes
    - Viewed (0)
  5. src/go/build/read_test.go

    		"syntax error",
    	},
    	{
    		`package p; import ("x"`,
    		"syntax error",
    	},
    }
    
    func TestReadFailuresIgnored(t *testing.T) {
    	// Syntax errors should not be reported (false arg to readImports).
    	// Instead, entire file should be the output and no error.
    	// Convert tests not to return syntax errors.
    	tests := make([]readTest, len(readFailuresTests))
    	copy(tests, readFailuresTests)
    	for i := range tests {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Oct 06 15:53:04 UTC 2021
    - 6K bytes
    - Viewed (0)
  6. src/cmd/go/internal/modcmd/vendor.go

    		}
    	}
    	if strings.HasSuffix(info.Name(), ".go") {
    		f, err := fsys.Open(filepath.Join(dir, info.Name()))
    		if err != nil {
    			base.Fatal(err)
    		}
    		defer f.Close()
    
    		content, err := imports.ReadImports(f, false, nil)
    		if err == nil && !imports.ShouldBuild(content, imports.AnyTags()) {
    			// The file is explicitly tagged "ignore", so it can't affect the build.
    			// Leave it out.
    			return false
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 14 14:19:59 UTC 2024
    - 14.5K bytes
    - Viewed (0)
  7. src/cmd/dist/build.go

    		// the generated files.
    	}
    
    	// Resolve imported packages to actual package paths.
    	// Make sure they're installed.
    	importMap := make(map[string]string)
    	for _, p := range gofiles {
    		for _, imp := range readimports(p) {
    			if imp == "C" {
    				fatalf("%s imports C", p)
    			}
    			importMap[imp] = resolveVendor(imp, dir)
    		}
    	}
    	sortedImports := make([]string, 0, len(importMap))
    	for imp := range importMap {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 20 18:34:40 UTC 2024
    - 54K bytes
    - Viewed (0)
Back to top