github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/pkg/couchdb/revision/rev.go (about)

     1  package revision
     2  
     3  import (
     4  	"strconv"
     5  	"strings"
     6  )
     7  
     8  // Generation returns the number before the hyphen, called the generation of a
     9  // revision.
    10  func Generation(rev string) int {
    11  	parts := strings.SplitN(rev, "-", 2)
    12  	gen, err := strconv.Atoi(parts[0])
    13  	if err != nil {
    14  		return 0
    15  	}
    16  	return gen
    17  }