Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for ExampleStructTag (0.11 sec)

  1. src/reflect/example_test.go

    	var floatSwap func(float64, float64) (float64, float64)
    	makeSwap(&floatSwap)
    	fmt.Println(floatSwap(2.72, 3.14))
    
    	// Output:
    	// 1 0
    	// 3.14 2.72
    }
    
    func ExampleStructTag() {
    	type S struct {
    		F string `species:"gopher" color:"blue"`
    	}
    
    	s := S{}
    	st := reflect.TypeOf(s)
    	field := st.Field(0)
    	fmt.Println(field.Tag.Get("color"), field.Tag.Get("species"))
    
    	// Output:
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 19 20:04:36 UTC 2022
    - 4.5K bytes
    - Viewed (0)
Back to top