github.com/searKing/golang/go@v1.2.117/exp/types/any_test.go (about)

     1  // Copyright 2023 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types_test
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"github.com/searKing/golang/go/exp/types"
    11  )
    12  
    13  type stringerVal struct {
    14  	s string
    15  }
    16  
    17  func (s stringerVal) String() string {
    18  	return s.s
    19  }
    20  
    21  func ExampleAny() {
    22  
    23  	fmt.Printf("%#v\n", (*stringerVal)(nil)) // typed nil implements [fmt.Stringer]
    24  	fmt.Printf("%#v\n", types.Any((*stringerVal)(nil)))
    25  
    26  	// Output:
    27  	// (*types_test.stringerVal)(nil)
    28  	// <nil>
    29  }