version.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 string = "0.9.3"
  20. func Full() string {
  21. return version
  22. }
  23. func Proto(v string) int64 {
  24. arr := strings.Split(v, ".")
  25. if len(arr) < 2 {
  26. return 0
  27. }
  28. res, _ := strconv.ParseInt(arr[0], 10, 64)
  29. return res
  30. }
  31. func Major(v string) int64 {
  32. arr := strings.Split(v, ".")
  33. if len(arr) < 2 {
  34. return 0
  35. }
  36. res, _ := strconv.ParseInt(arr[1], 10, 64)
  37. return res
  38. }
  39. func Minor(v string) int64 {
  40. arr := strings.Split(v, ".")
  41. if len(arr) < 2 {
  42. return 0
  43. }
  44. res, _ := strconv.ParseInt(arr[2], 10, 64)
  45. return res
  46. }
  47. // add every case there if server will not accept client's protocol and return false
  48. func Compat(client string, server string) bool {
  49. return true
  50. }