github.com/hedzr/evendeep@v0.4.8/diff/path.go (about)

     1  package diff
     2  
     3  import "strings"
     4  
     5  type Path struct {
     6  	parts []PathPart
     7  }
     8  
     9  func (dp Path) appendAndNew(parts ...PathPart) Path {
    10  	return Path{parts: append(dp.parts, parts...)}
    11  }
    12  
    13  func (dp Path) String() string {
    14  	var sb strings.Builder
    15  	for _, p := range dp.parts {
    16  		if sb.Len() > 0 {
    17  			sb.WriteRune('.')
    18  		}
    19  		sb.WriteString(p.String())
    20  	}
    21  	return sb.String()
    22  }
    23  
    24  type PathPart interface {
    25  	String() string
    26  }