| // Copyright 2013, 2014 Canonical Ltd. |
| // Licensed under the LGPLv3, see LICENCE file for details. |
| // prefixSize is used internally to trim the user specific path from the |
| // front of the returned filenames from the runtime call stack. |
| // goPath is the deduced path based on the location of this file as compiled. |
| _, file, _, ok := runtime.Caller(0) |
| // We know that the end of the file should be: |
| // github.com/juju/errors/path.go |
| suffix := len("github.com/juju/errors/path.go") |
| goPath = file[:size-suffix] |
| func trimGoPath(filename string) string { |
| if strings.HasPrefix(filename, goPath) { |
| return filename[prefixSize:] |