Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for noCmp (0.04 sec)

  1. test/interface/noeq.go

    // that cannot be compared for equality.
    
    package main
    
    func main() {
    	cmp(1)
    
    	var (
    		m map[int]int
    		s struct{ x []int }
    		f func()
    	)
    	noCmp(m)
    	noCmp(s)
    	noCmp(f)
    }
    
    func cmp(x interface{}) bool {
    	return x == x
    }
    
    func noCmp(x interface{}) {
    	shouldPanic(func() { cmp(x) })
    }
    
    func shouldPanic(f func()) {
    	defer func() {
    		if recover() == nil {
    			panic("function should panic")
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 02 13:43:18 UTC 2016
    - 641 bytes
    - Viewed (0)
Back to top