本文整理匯總了Golang中github.com/blang/semver.Version.Pre方法的典型用法代碼示例。如果您正苦於以下問題:Golang Version.Pre方法的具體用法?Golang Version.Pre怎麽用?Golang Version.Pre使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/blang/semver.Version
的用法示例。
在下文中一共展示了Version.Pre方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Apply
func (bump PreBump) Apply(v semver.Version) semver.Version {
if v.Pre == nil || v.Pre[0].VersionStr != bump.Pre {
v.Pre = []semver.PRVersion{
{VersionStr: bump.Pre},
{VersionNum: 1, IsNum: true},
}
} else {
v.Pre = []semver.PRVersion{
{VersionStr: bump.Pre},
{VersionNum: v.Pre[1].VersionNum + 1, IsNum: true},
}
}
return v
}
示例2:
Major: 1,
Minor: 2,
Patch: 3,
}
bump = version.PreBump{}
})
JustBeforeEach(func() {
outputVersion = bump.Apply(inputVersion)
})
Context("when the version is a prerelease", func() {
BeforeEach(func() {
inputVersion.Pre = []semver.PRVersion{
{VersionStr: "alpha"},
{VersionNum: 1, IsNum: true},
}
})
Context("when the bump is the same prerelease type", func() {
BeforeEach(func() {
bump.Pre = "alpha"
})
It("bumps the prerelease version number", func() {
Expect(outputVersion).To(Equal(semver.Version{
Major: 1,
Minor: 2,
Patch: 3,
Pre: []semver.PRVersion{
{VersionStr: "alpha"},
示例3: Apply
func (MinorBump) Apply(v semver.Version) semver.Version {
v.Minor++
v.Patch = 0
v.Pre = nil
return v
}
示例4: Apply
func (FinalBump) Apply(v semver.Version) semver.Version {
v.Pre = nil
return v
}
示例5:
Context(fmt.Sprintf("when bumping %s", bumpLocal), func() {
BeforeEach(func() {
bumpParam = bumpLocal
})
It("bumps to "+resultLocal, func() {
Ω(version.String()).Should(Equal(resultLocal))
})
})
}
Context("when it's already a prerelease", func() {
BeforeEach(func() {
version.Pre = []semver.PRVersion{
{VersionStr: "rc"},
{VersionNum: 1, IsNum: true},
}
})
for bump, result := range map[string]string{
"": "1.2.3-rc.2",
"final": "1.2.3-rc.1",
"patch": "1.2.4-rc.1",
"minor": "1.3.0-rc.1",
"major": "2.0.0-rc.1",
} {
bumpLocal := bump
resultLocal := result
Context(fmt.Sprintf("when bumping %s", bumpLocal), func() {
BeforeEach(func() {
示例6: Apply
func (PatchBump) Apply(v semver.Version) semver.Version {
v.Patch++
v.Pre = nil
return v
}