mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	hack/update-vendor.sh
This commit is contained in:
		
							
								
								
									
										51
									
								
								vendor/github.com/pkg/errors/stack.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								vendor/github.com/pkg/errors/stack.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -46,7 +46,8 @@ func (f Frame) line() int {
 | 
			
		||||
//
 | 
			
		||||
// Format accepts flags that alter the printing of some verbs, as follows:
 | 
			
		||||
//
 | 
			
		||||
//    %+s   path of source file relative to the compile time GOPATH
 | 
			
		||||
//    %+s   function name and path of source file relative to the compile time
 | 
			
		||||
//          GOPATH separated by \n\t (<funcname>\n\t<path>)
 | 
			
		||||
//    %+v   equivalent to %+s:%d
 | 
			
		||||
func (f Frame) Format(s fmt.State, verb rune) {
 | 
			
		||||
	switch verb {
 | 
			
		||||
@@ -79,6 +80,14 @@ func (f Frame) Format(s fmt.State, verb rune) {
 | 
			
		||||
// StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
 | 
			
		||||
type StackTrace []Frame
 | 
			
		||||
 | 
			
		||||
// Format formats the stack of Frames according to the fmt.Formatter interface.
 | 
			
		||||
//
 | 
			
		||||
//    %s	lists source files for each Frame in the stack
 | 
			
		||||
//    %v	lists the source file and line number for each Frame in the stack
 | 
			
		||||
//
 | 
			
		||||
// Format accepts flags that alter the printing of some verbs, as follows:
 | 
			
		||||
//
 | 
			
		||||
//    %+v   Prints filename, function, and line number for each Frame in the stack.
 | 
			
		||||
func (st StackTrace) Format(s fmt.State, verb rune) {
 | 
			
		||||
	switch verb {
 | 
			
		||||
	case 'v':
 | 
			
		||||
@@ -136,43 +145,3 @@ func funcname(name string) string {
 | 
			
		||||
	i = strings.Index(name, ".")
 | 
			
		||||
	return name[i+1:]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func trimGOPATH(name, file string) string {
 | 
			
		||||
	// Here we want to get the source file path relative to the compile time
 | 
			
		||||
	// GOPATH. As of Go 1.6.x there is no direct way to know the compiled
 | 
			
		||||
	// GOPATH at runtime, but we can infer the number of path segments in the
 | 
			
		||||
	// GOPATH. We note that fn.Name() returns the function name qualified by
 | 
			
		||||
	// the import path, which does not include the GOPATH. Thus we can trim
 | 
			
		||||
	// segments from the beginning of the file path until the number of path
 | 
			
		||||
	// separators remaining is one more than the number of path separators in
 | 
			
		||||
	// the function name. For example, given:
 | 
			
		||||
	//
 | 
			
		||||
	//    GOPATH     /home/user
 | 
			
		||||
	//    file       /home/user/src/pkg/sub/file.go
 | 
			
		||||
	//    fn.Name()  pkg/sub.Type.Method
 | 
			
		||||
	//
 | 
			
		||||
	// We want to produce:
 | 
			
		||||
	//
 | 
			
		||||
	//    pkg/sub/file.go
 | 
			
		||||
	//
 | 
			
		||||
	// From this we can easily see that fn.Name() has one less path separator
 | 
			
		||||
	// than our desired output. We count separators from the end of the file
 | 
			
		||||
	// path until it finds two more than in the function name and then move
 | 
			
		||||
	// one character forward to preserve the initial path segment without a
 | 
			
		||||
	// leading separator.
 | 
			
		||||
	const sep = "/"
 | 
			
		||||
	goal := strings.Count(name, sep) + 2
 | 
			
		||||
	i := len(file)
 | 
			
		||||
	for n := 0; n < goal; n++ {
 | 
			
		||||
		i = strings.LastIndex(file[:i], sep)
 | 
			
		||||
		if i == -1 {
 | 
			
		||||
			// not enough separators found, set i so that the slice expression
 | 
			
		||||
			// below leaves file unmodified
 | 
			
		||||
			i = -len(sep)
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// get back to 0 or trim the leading separator
 | 
			
		||||
	file = file[i+len(sep):]
 | 
			
		||||
	return file
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user