Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 106 for mkstruct (0.12 sec)

  1. test/typeparam/issue51219.dir/a.go

    // via a type constraint.  (In this test, I -> IConstraint -> MyStruct -> I.)
    type JsonRaw []byte
    
    type MyStruct struct {
    	x *I[JsonRaw]
    }
    
    type IConstraint interface {
    	JsonRaw | MyStruct
    }
    
    type I[T IConstraint] struct {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Feb 28 14:59:04 UTC 2022
    - 487 bytes
    - Viewed (0)
  2. test/interface/struct.go

    package main
    
    import "os"
    
    var fail int
    
    func check(b bool, msg string) {
    	if (!b) {
    		println("failure in", msg)
    		fail++
    	}
    }
    
    type I1 interface { Get() int; Put(int) }
    
    type S1 struct { i int }
    func (p S1) Get() int { return p.i }
    func (p S1) Put(i int) { p.i = i }
    
    func f1() {
    	s := S1{1}
    	var i I1 = s
    	i.Put(2)
    	check(i.Get() == 1, "f1 i")
    	check(s.i == 1, "f1 s")
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sun Feb 19 06:33:41 UTC 2012
    - 2.4K bytes
    - Viewed (0)
  3. test/typeparam/issue50109.go

    	return NewAny[T]()
    }
    
    type MyStruct struct {
    	Name string
    }
    
    func main() {
    	// Create a generic cache.
    	// All items are cached as interface{} so they need to be cast back to their
    	// original type when retrieved.
    	// Failure in issue doesn't happen with 'any' replaced by 'interface{}'
    	c := NewAnyCacher[any]()
    
    	myStruct := &MyStruct{"MySuperStruct"}
    
    	c.Set("MySuperStruct", myStruct)
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 01 19:45:34 UTC 2022
    - 2.2K bytes
    - Viewed (0)
  4. test/fixedbugs/issue24547.go

    // based on the promoted method, not the shadowed method.
    
    package main
    
    import (
    	"bytes"
    	"fmt"
    )
    
    type mystruct struct {
    	f int
    }
    
    func (t mystruct) String() string {
    	return "FAIL"
    }
    
    func main() {
    	type deep struct {
    		mystruct
    	}
    	s := struct {
    		deep
    		*bytes.Buffer
    	}{
    		deep{},
    		bytes.NewBufferString("ok"),
    	}
    
    	if got := s.String(); got != "ok" {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 27 18:56:36 UTC 2018
    - 757 bytes
    - Viewed (0)
  5. src/cmd/compile/internal/types2/struct.go

    )
    
    // ----------------------------------------------------------------------------
    // API
    
    // A Struct represents a struct type.
    type Struct struct {
    	fields []*Var   // fields != nil indicates the struct is set up (possibly with len(fields) == 0)
    	tags   []string // field tags; nil if there are no tags
    }
    
    // NewStruct returns a new struct with the given fields and corresponding field tags.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 29 22:06:18 UTC 2024
    - 6.6K bytes
    - Viewed (0)
  6. test/typeparam/struct.go

    // license that can be found in the LICENSE file.
    
    package main
    
    import (
    	"fmt"
    )
    
    type E[T any] struct {
    	v T
    }
    
    type S1 struct {
    	E[int]
    	v string
    }
    
    type Eint = E[int]
    type Ebool = E[bool]
    type Eint2 = Eint
    
    type S2 struct {
    	Eint
    	Ebool
    	v string
    }
    
    type S3 struct {
    	*E[int]
    }
    
    func main() {
    	s1 := S1{Eint{2}, "foo"}
    	if got, want := s1.E.v, 2; got != want {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Apr 05 16:29:58 UTC 2024
    - 801 bytes
    - Viewed (0)
  7. src/go/types/struct.go

    )
    
    // ----------------------------------------------------------------------------
    // API
    
    // A Struct represents a struct type.
    type Struct struct {
    	fields []*Var   // fields != nil indicates the struct is set up (possibly with len(fields) == 0)
    	tags   []string // field tags; nil if there are no tags
    }
    
    // NewStruct returns a new struct with the given fields and corresponding field tags.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 29 22:06:18 UTC 2024
    - 6.1K bytes
    - Viewed (0)
  8. src/internal/types/testdata/check/compliterals.go

    // license that can be found in the LICENSE file.
    
    // Composite literals with parameterized types
    
    package comp_literals
    
    type myStruct struct {
    	f int
    }
    
    type slice[E any] []E
    
    func struct_literals[S struct{f int}|myStruct]() {
    	_ = S{}
    	_ = S{0}
    	_ = S{f: 0}
    
            _ = slice[int]{1, 2, 3}
            _ = slice[S]{{}, {0}, {f:0}}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Sep 02 02:58:32 UTC 2022
    - 442 bytes
    - Viewed (0)
  9. src/internal/types/testdata/examples/functions.go

    	_ = s1
    
    	type myStruct struct{x int}
    	var s2 myStruct
    	g3(nil, struct{x int}{}, myStruct{})
    	g3(&s2, struct{x int}{}, myStruct{})
    	g3(nil, myStruct{}, struct{x int}{})
    	g3(&s2, myStruct{}, struct{x int}{})
    }
    
    // Here's a realistic example.
    
    func append[T any](s []T, t ...T) []T { panic(0) }
    
    func _() {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 30 20:19:38 UTC 2023
    - 5.5K bytes
    - Viewed (0)
  10. src/go/printer/testdata/alignment.golden

    // Examples from issue #7335.
    
    func main() {
    	z := MyStruct{
    		Foo:		"foo",
    		Bar:		"bar",
    		Name:		"name",
    		LongName:	"longname",
    		Baz:		"baz",
    	}
    	y := MyStruct{
    		Foo:			"foo",
    		Bar:			"bar",
    		NameXX:			"name",
    		LongNameXXXXXXXXXXXXX:	"longname",
    		Baz:			"baz",
    	}
    	z := MyStruct{
    		Foo:			"foo",
    		Bar:			"bar",
    		Name:			"name",
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Aug 14 20:40:15 UTC 2018
    - 4.1K bytes
    - Viewed (0)
Back to top