Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 14 for TypeFor (0.14 sec)

  1. src/reflect/type_test.go

    	)
    
    	testcases := []struct {
    		wantFrom any
    		got      reflect.Type
    	}{
    		{new(int), reflect.TypeFor[int]()},
    		{new(int64), reflect.TypeFor[int64]()},
    		{new(string), reflect.TypeFor[string]()},
    		{new(mystring), reflect.TypeFor[mystring]()},
    		{new(any), reflect.TypeFor[any]()},
    		{new(myiface), reflect.TypeFor[myiface]()},
    	}
    	for _, tc := range testcases {
    		want := reflect.ValueOf(tc.wantFrom).Elem().Type()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 15 23:39:44 UTC 2024
    - 4.2K bytes
    - Viewed (0)
  2. src/cmd/vet/testdata/stdversion/stdversion.go

    package stdversion
    
    import "reflect"
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 03 01:02:40 UTC 2024
    - 142 bytes
    - Viewed (0)
  3. src/encoding/gob/type_test.go

    	newtyp := getTypeUnlocked("int", reflect.TypeFor[int]())
    	if newtyp != tInt.gobType() {
    		t.Errorf("reregistration of %s got new type", newtyp.string())
    	}
    	newtyp = getTypeUnlocked("uint", reflect.TypeFor[uint]())
    	if newtyp != tUint.gobType() {
    		t.Errorf("reregistration of %s got new type", newtyp.string())
    	}
    	newtyp = getTypeUnlocked("string", reflect.TypeFor[string]())
    	if newtyp != tString.gobType() {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Aug 01 14:26:13 UTC 2023
    - 6.1K bytes
    - Viewed (0)
  4. src/unique/clone_test.go

    	testCloneSeq[testStruct](t, cSeq(8))
    }
    
    func cSeq(stringOffsets ...uintptr) cloneSeq {
    	return cloneSeq{stringOffsets: stringOffsets}
    }
    
    func testCloneSeq[T any](t *testing.T, want cloneSeq) {
    	typName := reflect.TypeFor[T]().Name()
    	typ := abi.TypeOf(*new(T))
    	t.Run(typName, func(t *testing.T) {
    		got := makeCloneSeq(typ)
    		if !reflect.DeepEqual(got, want) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Apr 22 18:14:07 UTC 2024
    - 1K bytes
    - Viewed (0)
  5. src/cmd/fix/cftype.go

    	// There's no easy way to map from an ast.Expr to all the places that use them, so
    	// we use reflect to find all such references.
    	if len(badNils) > 0 {
    		exprType := reflect.TypeFor[ast.Expr]()
    		exprSliceType := reflect.TypeFor[[]ast.Expr]()
    		walk(f, func(n any) {
    			if n == nil {
    				return
    			}
    			v := reflect.ValueOf(n)
    			if v.Type().Kind() != reflect.Pointer {
    				return
    			}
    			if v.IsNil() {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Aug 07 00:25:49 UTC 2023
    - 3.5K bytes
    - Viewed (0)
  6. pkg/typemap/map.go

    }
    
    func Set[T any](t TypeMap, v T) {
    	interfaceType := reflect.TypeOf((*T)(nil)).Elem()
    	t.inner[interfaceType] = v
    }
    
    func Get[T any](t TypeMap) *T {
    	v, f := t.inner[reflect.TypeFor[T]()]
    	if f {
    		return ptr.Of(v.(T))
    	}
    	return nil
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed Apr 17 16:38:40 UTC 2024
    - 1.2K bytes
    - Viewed (0)
  7. src/html/template/content.go

    		return a
    	}
    	v := reflect.ValueOf(a)
    	for v.Kind() == reflect.Pointer && !v.IsNil() {
    		v = v.Elem()
    	}
    	return v.Interface()
    }
    
    var (
    	errorType       = reflect.TypeFor[error]()
    	fmtStringerType = reflect.TypeFor[fmt.Stringer]()
    )
    
    // indirectToStringerOrError returns the value, after dereferencing as many times
    // as necessary to reach the base type (or nil) or an implementation of fmt.Stringer
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Aug 01 14:30:25 UTC 2023
    - 6.2K bytes
    - Viewed (0)
  8. src/net/http/transfer_test.go

    func (w *mockTransferWriter) Write(p []byte) (int, error) {
    	w.WriteCalled = true
    	return io.Discard.Write(p)
    }
    
    func TestTransferWriterWriteBodyReaderTypes(t *testing.T) {
    	fileType := reflect.TypeFor[*os.File]()
    	bufferType := reflect.TypeFor[*bytes.Buffer]()
    
    	nBytes := int64(1 << 10)
    	newFileFunc := func() (r io.Reader, done func(), err error) {
    		f, err := os.CreateTemp("", "net-http-newfilefunc")
    		if err != nil {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 17 23:16:28 UTC 2023
    - 9.1K bytes
    - Viewed (0)
  9. src/unique/handle_test.go

    		s: [2]testStringStruct{testStringStruct{"y"}, testStringStruct{"z"}},
    	})
    	testHandle[testStruct](t, testStruct{0.5, "184"})
    }
    
    func testHandle[T comparable](t *testing.T, value T) {
    	name := reflect.TypeFor[T]().Name()
    	t.Run(fmt.Sprintf("%s/%#v", name, value), func(t *testing.T) {
    		t.Parallel()
    
    		v0 := Make(value)
    		v1 := Make(value)
    
    		if v0.Value() != v1.Value() {
    			t.Error("v0.Value != v1.Value")
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Apr 22 18:14:07 UTC 2024
    - 2.5K bytes
    - Viewed (0)
  10. doc/next/3-tools.md

    by any [`//go:build` constraints](https://pkg.go.dev/cmd/go#hdr-Build_constraints)
    in the file.)
    
    For example, it will report a diagnostic for a reference to the
    `reflect.TypeFor` function (introduced in go1.22) from a file in a
    module whose go.mod file specifies `go 1.21`.
    
    ### Cgo {#cgo}
    
    <!-- go.dev/issue/66456 -->
    [cmd/cgo] supports the new `-ldflags` flag for passing flags to the C linker.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 28 19:06:07 UTC 2024
    - 3.4K bytes
    - Viewed (0)
Back to top