本文整理匯總了Golang中github.com/juju/juju/version.Binary.Number方法的典型用法代碼示例。如果您正苦於以下問題:Golang Binary.Number方法的具體用法?Golang Binary.Number怎麽用?Golang Binary.Number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/version.Binary
的用法示例。
在下文中一共展示了Binary.Number方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetMockBuildTools
// GetMockBuildTools returns a sync.BuildToolsTarballFunc implementation which generates
// a fake tools tarball.
func GetMockBuildTools(c *gc.C) sync.BuildToolsTarballFunc {
return func(forceVersion *version.Number, stream string) (*sync.BuiltTools, error) {
vers := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
if forceVersion != nil {
vers.Number = *forceVersion
}
tgz, checksum := coretesting.TarGz(
coretesting.NewTarFile(names.Jujud, 0777, "jujud contents "+vers.String()))
toolsDir, err := ioutil.TempDir("", "juju-tools-"+stream)
c.Assert(err, jc.ErrorIsNil)
name := "name"
ioutil.WriteFile(filepath.Join(toolsDir, name), tgz, 0777)
return &sync.BuiltTools{
Dir: toolsDir,
StorageName: name,
Version: vers,
Size: int64(len(tgz)),
Sha256Hash: checksum,
}, nil
}
}
示例2: makeToolsList
func makeToolsList(series string) tools.List {
var toolsVersion version.Binary
toolsVersion.Number = version.MustParse("1.26.0")
toolsVersion.Arch = arch.AMD64
toolsVersion.Series = series
return tools.List{{
Version: toolsVersion,
URL: fmt.Sprintf("http://example.com/tools/juju-%s.tgz", toolsVersion),
SHA256: "1234567890abcdef",
Size: 1024,
}}
}
示例3: GetMockBundleTools
func GetMockBundleTools(c *gc.C) tools.BundleToolsFunc {
return func(w io.Writer, forceVersion *version.Number) (version.Binary, string, error) {
vers := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
if forceVersion != nil {
vers.Number = *forceVersion
}
sha256Hash := fmt.Sprintf("%x", sha256.New().Sum(nil))
return vers, sha256Hash, nil
}
}