String converts a Version object to a string. Note, if the original version contained a leading v this version will not. See the Original() method to retrieve the original value. Semantic Versions don't contain a leading v per the spec. Instead it's optional on implementation.
()
| 338 | // don't contain a leading v per the spec. Instead it's optional on |
| 339 | // implementation. |
| 340 | func (v Version) String() string { |
| 341 | var buf bytes.Buffer |
| 342 | |
| 343 | fmt.Fprintf(&buf, "%d.%d.%d", v.major, v.minor, v.patch) |
| 344 | if v.pre != "" { |
| 345 | fmt.Fprintf(&buf, "-%s", v.pre) |
| 346 | } |
| 347 | if v.metadata != "" { |
| 348 | fmt.Fprintf(&buf, "+%s", v.metadata) |
| 349 | } |
| 350 | |
| 351 | return buf.String() |
| 352 | } |
| 353 | |
| 354 | // Original returns the original value passed in to be parsed. |
| 355 | func (v *Version) Original() string { |
no outgoing calls