-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for semver serealization (#26)
Will be made obsolete when Masterminds/semver#228 is merged
- Loading branch information
1 parent
51868cc
commit e323400
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package plugin | ||
|
||
import "github.com/Masterminds/semver/v3" | ||
|
||
// semver.Version doesn't implement MarshalBinary/UnmarshalBinary required for | ||
// gob (which is required by net/rpc, which is required by go-plugin). | ||
// This is a temporary workaround, I expect they are going to add these methods | ||
// after [my PR](https://github.com/Masterminds/semver/pull/228) is accepted | ||
|
||
type Version semver.Version | ||
|
||
func (v Version) MarshalBinary() ([]byte, error) { | ||
return semver.Version(v).MarshalText() | ||
} | ||
|
||
func (v *Version) UnmarshalBinary(data []byte) error { | ||
return (*semver.Version)(v).UnmarshalText(data) | ||
} | ||
|
||
// Returns the wrapped `semver.Version`. | ||
func (v *Version) Cast() *semver.Version { | ||
return (*semver.Version)(v) | ||
} |