github.com/sirkon/goproxy@v1.4.8/plugin/gitlab/version_lde.go (about) 1 /* 2 This file was autogenerated via 3 ---------------------------------------- 4 ldetool generate --go-string version.lde 5 ---------------------------------------- 6 do not touch it with bare hands! 7 */ 8 9 package gitlab 10 11 import ( 12 "strconv" 13 14 "github.com/sirkon/goproxy/internal/errors" 15 ) 16 17 // pathVersionExtractor ... 18 type pathVersionExtractor struct { 19 Rest string 20 Version int 21 } 22 23 // Extract ... 24 func (p *pathVersionExtractor) Extract(line string) (bool, error) { 25 p.Rest = line 26 var err error 27 var tmpInt int64 28 29 // Checks if the rest starts with 'v' and pass it 30 if len(p.Rest) >= 1 && p.Rest[0] == 'v' { 31 p.Rest = p.Rest[1:] 32 } else { 33 return false, nil 34 } 35 36 // Take the rest as Version(int) 37 if tmpInt, err = strconv.ParseInt(p.Rest, 10, 64); err != nil { 38 return false, errors.Wrapf(err, "parsing `%s` into field Version(int)", p.Rest) 39 } 40 p.Version = int(tmpInt) 41 p.Rest = p.Rest[len(p.Rest):] 42 return true, nil 43 }