github.com/searKing/golang/go@v1.2.117/error/cause/example_test.go (about) 1 // Copyright 2020 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 cause_test 6 7 import ( 8 "errors" 9 "fmt" 10 11 "github.com/searKing/golang/go/error/cause" 12 ) 13 14 func ExampleWithError() { 15 cause_ := errors.New("whoops") 16 err := fmt.Errorf("oh noes") 17 err = cause.WithError(cause_, err) 18 fmt.Println(err) 19 20 // Output: oh noes: whoops 21 }