This topic describes how to download the required RPM packages by using obshell-sdk-go.
Note
Before you proceed, we recommend that you read Get Started with obshell-sdk-go to learn how to use obshell-sdk-go.
Sample code
Download the latest RPM package
package main import ( "fmt" "github.com/oceanbase/obshell-sdk-go/util" ) // Download the latest obshell package for the same architecture as the execution machine. func DownloadSameArch() { entry := util.PackageEntry{ Name: "obshell", } dest, err := util.DownloadPackage("/root/download", entry) if err != nil { panic(err) } fmt.Println(dest) }Download an RPM package of a specified version
package main import ( "fmt" "github.com/oceanbase/obshell-sdk-go/util" ) // Download the specified version of the OceanBase Database Community Edition package for the same architecture as the execution machine. func DownloadSameArchVersion() { entry := util.PackageEntry{ Name: "oceanbase-ce", Version: "4.3.5.0", } dest, err := util.DownloadPackage("/root/download", entry) if err != nil { panic(err) } fmt.Println(dest) }
Download the latest RPM package
package main import ( "fmt" "github.com/oceanbase/obshell-sdk-go/util" ) func DownloadDiffArch() { // Download the latest obshell package for the specified architecture. entry := util.PackageEntry{ Name: "obshell", } // Specify the architecture and system as aarch64 and el8, respectively. mirror := util.OB_COMMUNITY_STABLE_BASE.GetMirror(util.AARCH64, util.EL8) dest, err := mirror.Download("/root/download", entry) if err != nil { panic(err) } fmt.Println(dest) }Download an RPM package of a specified version
package main import ( "fmt" "github.com/oceanbase/obshell-sdk-go/util" ) // Download the obshell package of the specified version for the specified architecture func DownloadDiffArchVersion() { entry := util.PackageEntry{ Name: "obshell", Version: "4.2.4.0", } // Specify the architecture and system as aarch64 and el8 respectively. mirror := util.OB_COMMUNITY_STABLE_BASE.GetMirror(util.AARCH64, util.EL8) dest, err := mirror.Download("/root/download", entry) if err != nil { panic(err) } fmt.Println(dest) }
Related Documents
For more information about how to request the API method using obshell-sdk-python, see Download the RPM package.