Search Options

Results per page
Sort
Preferred Languages
Advance

Results 31 - 40 of 151 for Fset (0.04 sec)

  1. src/go/parser/example_test.go

    import (
    	"fmt"
    	"go/parser"
    	"go/token"
    )
    
    func ExampleParseFile() {
    	fset := token.NewFileSet() // positions are relative to fset
    
    	src := `package foo
    
    import (
    	"fmt"
    	"time"
    )
    
    func bar() {
    	fmt.Println(time.Now())
    }`
    
    	// Parse src but stop after processing the imports.
    	f, err := parser.ParseFile(fset, "", src, parser.ImportsOnly)
    	if err != nil {
    		fmt.Println(err)
    		return
    	}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Apr 03 16:07:09 UTC 2017
    - 715 bytes
    - Viewed (0)
  2. src/go/types/lookup_test.go

    	// Choose an arbitrary, large package.
    	path := filepath.Join(runtime.GOROOT(), "src", "net", "http")
    
    	fset := token.NewFileSet()
    	files, err := pkgFiles(fset, path)
    	if err != nil {
    		b.Fatal(err)
    	}
    
    	conf := Config{
    		Importer: importer.Default(),
    	}
    
    	pkg, err := conf.Check("http", fset, files, nil)
    	if err != nil {
    		b.Fatal(err)
    	}
    
    	scope := pkg.Scope()
    	names := scope.Names()
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 13 15:31:43 UTC 2022
    - 1.2K bytes
    - Viewed (0)
  3. src/go/types/methodset.go

    				}
    				seen.add(named)
    
    				for i := 0; i < named.NumMethods(); i++ {
    					mset = mset.addOne(named.Method(i), concat(e.index, i), e.indirect, e.multiples)
    				}
    			}
    
    			switch t := under(typ).(type) {
    			case *Struct:
    				for i, f := range t.fields {
    					if fset == nil {
    						fset = make(map[string]bool)
    					}
    					fset[f.Id()] = true
    
    					// Embedded fields are always of the form T or *T where
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 12:02:03 UTC 2023
    - 7.1K bytes
    - Viewed (0)
  4. src/go/format/example_test.go

    	node, err := parser.ParseExpr(expr)
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	// Create a FileSet for node. Since the node does not come
    	// from a real source file, fset will be empty.
    	fset := token.NewFileSet()
    
    	var buf bytes.Buffer
    	err = format.Node(&buf, fset, node)
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	fmt.Println(buf.String())
    
    	// Output: (6 + 2*3) / 4
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Mar 19 17:49:53 UTC 2018
    - 753 bytes
    - Viewed (0)
  5. src/go/types/methodset_test.go

    		obj1, _, _ := LookupFieldOrMethod(recv, false, pkg, name)
    		mset := NewMethodSet(recv)
    		if (obj1 != nil) != (mset.Len() == 1) {
    			t.Fatalf("lookup(%v.%s): got obj = %v, mset = %v", recv, name, obj1, mset)
    		}
    		// If the method exists, both must return the same object.
    		if obj1 != nil {
    			obj2 := mset.At(0).Obj()
    			if obj1 != obj2 {
    				t.Fatalf("%v != %v", obj1, obj2)
    			}
    		}
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jun 08 15:27:57 UTC 2023
    - 6.7K bytes
    - Viewed (0)
  6. src/go/ast/filter_test.go

    func (t2) f1() {}
    
    func (x *t2) f2() {}
    `
    
    func TestFilterDuplicates(t *testing.T) {
    	// parse input
    	fset := token.NewFileSet()
    	file, err := parser.ParseFile(fset, "", input, 0)
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	// create package
    	files := map[string]*ast.File{"": file}
    	pkg, err := ast.NewPackage(fset, files, nil, nil)
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	// filter
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Sep 09 15:35:30 UTC 2022
    - 1.6K bytes
    - Viewed (0)
  7. src/go/importer/importer.go

    // Deprecated: If lookup is nil, for backwards-compatibility, the importer
    // will attempt to resolve imports in the $GOPATH workspace.
    func ForCompiler(fset *token.FileSet, compiler string, lookup Lookup) types.Importer {
    	switch compiler {
    	case "gc":
    		return &gcimports{
    			fset:     fset,
    			packages: make(map[string]*types.Package),
    			lookup:   lookup,
    		}
    
    	case "gccgo":
    		var inst gccgoimporter.GccgoInstallation
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 12:02:03 UTC 2023
    - 3.6K bytes
    - Viewed (0)
  8. src/go/ast/commentmap.go

    func NewCommentMap(fset *token.FileSet, node Node, comments []*CommentGroup) CommentMap {
    	if len(comments) == 0 {
    		return nil // no comments to map
    	}
    
    	cmap := make(CommentMap)
    
    	// set up comment reader r
    	tmp := make([]*CommentGroup, len(comments))
    	copy(tmp, comments) // don't change incoming comments
    	sortComments(tmp)
    	r := commentListReader{fset: fset, list: tmp} // !r.eol() because len(comments) > 0
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 8.9K bytes
    - Viewed (0)
  9. src/cmd/fix/main.go

    		return err
    	}
    
    	file, err := parser.ParseFile(fset, filename, src, parserMode)
    	if err != nil {
    		return err
    	}
    
    	// Make sure file is in canonical format.
    	// This "fmt" pseudo-fix cannot be disabled.
    	newSrc, err := gofmtFile(file)
    	if err != nil {
    		return err
    	}
    	if !bytes.Equal(newSrc, src) {
    		newFile, err := parser.ParseFile(fset, filename, newSrc, parserMode)
    		if err != nil {
    			return err
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 14 19:41:17 UTC 2024
    - 5.4K bytes
    - Viewed (0)
  10. src/go/token/example_test.go

    		// The absolute position is the exact position in the source.
    		pos := decl.Pos()
    		relPosition := fset.Position(pos)
    		absPosition := fset.PositionFor(pos, false)
    
    		// Either a FuncDecl or GenDecl, since we exit on error.
    		kind := "func"
    		if gen, ok := decl.(*ast.GenDecl); ok {
    			kind = gen.Tok.String()
    		}
    
    		// If the relative and absolute positions differ, show both.
    		fmtPosition := relPosition.String()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 09 22:09:31 UTC 2023
    - 1.7K bytes
    - Viewed (0)
Back to top