Created
November 1, 2022 20:40
-
-
Save autarch/24ff9eae44a33512c39c82696424a35e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// BuildInfo represents a response for the buildInfo command. | |
type BuildInfo struct { | |
Version string | |
VersionArray []int `bson:"versionArray"` // On MongoDB 2.0+; assembled from Version otherwise | |
GitVersion string `bson:"gitVersion"` | |
OpenSSLVersion string `bson:"OpenSSLVersion"` | |
SysInfo string `bson:"sysInfo"` // Deprecated and empty on MongoDB 3.2+. | |
Bits int | |
Debug bool | |
MaxObjectSize int `bson:"maxBsonObjectSize"` | |
} | |
// VersionAtLeast returns whether the BuildInfo version is greater than or | |
// equal to the provided version number. If more than one number is | |
// provided, numbers will be considered as major, minor, and so on. | |
func (bi *BuildInfo) VersionAtLeast(version ...int) bool { | |
for i, vi := range version { | |
if i == len(bi.VersionArray) { | |
return false | |
} | |
if bivi := bi.VersionArray[i]; bivi != vi { | |
return bivi >= vi | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment