github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/vcmock/utils.go (about) 1 // Copyright (c) 2017 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package vcmock 7 8 import ( 9 "runtime" 10 "strings" 11 ) 12 13 // getSelf returns the name of the _calling_ function 14 func getSelf() string { 15 pc := make([]uintptr, 1) 16 17 // return the program counter for the calling function 18 runtime.Callers(2, pc) 19 20 f := runtime.FuncForPC(pc[0]) 21 return f.Name() 22 } 23 24 // IsMockError returns true if the specified error was generated by this 25 // package. 26 func IsMockError(err error) bool { 27 return strings.HasPrefix(err.Error(), mockErrorPrefix) 28 }