version.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2016 fatedier, fatedier@gmail.com
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package version
  15. import (
  16. "strconv"
  17. "strings"
  18. )
  19. var version = "0.52.3"
  20. func Full() string {
  21. return version
  22. }
  23. func getSubVersion(v string, position int) int64 {
  24. arr := strings.Split(v, ".")
  25. if len(arr) < 3 {
  26. return 0
  27. }
  28. res, _ := strconv.ParseInt(arr[position], 10, 64)
  29. return res
  30. }
  31. func Proto(v string) int64 {
  32. return getSubVersion(v, 0)
  33. }
  34. func Major(v string) int64 {
  35. return getSubVersion(v, 1)
  36. }
  37. func Minor(v string) int64 {
  38. return getSubVersion(v, 2)
  39. }