Skip to content

Commit 6eff27a

Browse files
committed
change Version to only have pointer receivers
1 parent f4a4d83 commit 6eff27a

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

version.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func MustParse(v string) *Version {
240240
// See the Original() method to retrieve the original value. Semantic Versions
241241
// don't contain a leading v per the spec. Instead it's optional on
242242
// implementation.
243-
func (v Version) String() string {
243+
func (v *Version) String() string {
244244
var buf bytes.Buffer
245245

246246
fmt.Fprintf(&buf, "%d.%d.%d", v.major, v.minor, v.patch)
@@ -260,32 +260,32 @@ func (v *Version) Original() string {
260260
}
261261

262262
// Major returns the major version.
263-
func (v Version) Major() uint64 {
263+
func (v *Version) Major() uint64 {
264264
return v.major
265265
}
266266

267267
// Minor returns the minor version.
268-
func (v Version) Minor() uint64 {
268+
func (v *Version) Minor() uint64 {
269269
return v.minor
270270
}
271271

272272
// Patch returns the patch version.
273-
func (v Version) Patch() uint64 {
273+
func (v *Version) Patch() uint64 {
274274
return v.patch
275275
}
276276

277277
// Prerelease returns the pre-release version.
278-
func (v Version) Prerelease() string {
278+
func (v *Version) Prerelease() string {
279279
return v.pre
280280
}
281281

282282
// Metadata returns the metadata on the version.
283-
func (v Version) Metadata() string {
283+
func (v *Version) Metadata() string {
284284
return v.metadata
285285
}
286286

287287
// originalVPrefix returns the original 'v' prefix if any.
288-
func (v Version) originalVPrefix() string {
288+
func (v *Version) originalVPrefix() string {
289289
// Note, only lowercase v is supported as a prefix by the parser.
290290
if v.original != "" && v.original[:1] == "v" {
291291
return v.original[:1]
@@ -298,8 +298,8 @@ func (v Version) originalVPrefix() string {
298298
// it unsets metadata and prerelease values, increments patch number.
299299
// If the current version has any of prerelease or metadata information,
300300
// it unsets both values and keeps current patch value
301-
func (v Version) IncPatch() Version {
302-
vNext := v
301+
func (v *Version) IncPatch() Version {
302+
vNext := *v
303303
// according to http://semver.org/#spec-item-9
304304
// Pre-release versions have a lower precedence than the associated normal version.
305305
// according to http://semver.org/#spec-item-10
@@ -321,8 +321,8 @@ func (v Version) IncPatch() Version {
321321
// Increments minor number.
322322
// Unsets metadata.
323323
// Unsets prerelease status.
324-
func (v Version) IncMinor() Version {
325-
vNext := v
324+
func (v *Version) IncMinor() Version {
325+
vNext := *v
326326
vNext.metadata = ""
327327
vNext.pre = ""
328328
vNext.patch = 0
@@ -337,8 +337,8 @@ func (v Version) IncMinor() Version {
337337
// Increments major number.
338338
// Unsets metadata.
339339
// Unsets prerelease status.
340-
func (v Version) IncMajor() Version {
341-
vNext := v
340+
func (v *Version) IncMajor() Version {
341+
vNext := *v
342342
vNext.metadata = ""
343343
vNext.pre = ""
344344
vNext.patch = 0
@@ -350,8 +350,8 @@ func (v Version) IncMajor() Version {
350350

351351
// SetPrerelease defines the prerelease value.
352352
// Value must not include the required 'hyphen' prefix.
353-
func (v Version) SetPrerelease(prerelease string) (Version, error) {
354-
vNext := v
353+
func (v *Version) SetPrerelease(prerelease string) (Version, error) {
354+
vNext := *v
355355
if len(prerelease) > 0 {
356356
if err := validatePrerelease(prerelease); err != nil {
357357
return vNext, err
@@ -364,8 +364,8 @@ func (v Version) SetPrerelease(prerelease string) (Version, error) {
364364

365365
// SetMetadata defines metadata value.
366366
// Value must not include the required 'plus' prefix.
367-
func (v Version) SetMetadata(metadata string) (Version, error) {
368-
vNext := v
367+
func (v *Version) SetMetadata(metadata string) (Version, error) {
368+
vNext := *v
369369
if len(metadata) > 0 {
370370
if err := validateMetadata(metadata); err != nil {
371371
return vNext, err
@@ -466,7 +466,7 @@ func (v *Version) UnmarshalJSON(b []byte) error {
466466
}
467467

468468
// MarshalJSON implements JSON.Marshaler interface.
469-
func (v Version) MarshalJSON() ([]byte, error) {
469+
func (v *Version) MarshalJSON() ([]byte, error) {
470470
return json.Marshal(v.String())
471471
}
472472

@@ -483,7 +483,7 @@ func (v *Version) UnmarshalText(text []byte) error {
483483
}
484484

485485
// MarshalText implements the encoding.TextMarshaler interface.
486-
func (v Version) MarshalText() ([]byte, error) {
486+
func (v *Version) MarshalText() ([]byte, error) {
487487
return []byte(v.String()), nil
488488
}
489489

@@ -505,7 +505,7 @@ func (v *Version) Scan(value interface{}) error {
505505
}
506506

507507
// Value implements the Driver.Valuer interface.
508-
func (v Version) Value() (driver.Value, error) {
508+
func (v *Version) Value() (driver.Value, error) {
509509
return v.String(), nil
510510
}
511511

0 commit comments

Comments
 (0)