mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-08-26 23:28:09 +00:00
* switch branches * update user interface * switch branch * switch branch * change branch * submit 0.3.3 * Update UI * update version function * Update UI * Update user.go * update disk * update person info interface * Update main.go * Update UI * update alpha * updata ui * Update assist.sh * Update assist.sh * update update function * add upload sh * Update init.go * upload shell script * Update system.go * update update.sh * Update init.go * update update.sh * update update.sh * Update update.sh * Update system.go * Update system.go * update UI * Update CHANGELOG.md
48 lines
936 B
Go
48 lines
936 B
Go
/*
|
|
* @Author: LinkLeong link@icewhale.com
|
|
* @Date: 2022-05-13 18:15:46
|
|
* @LastEditors: LinkLeong
|
|
* @LastEditTime: 2022-06-29 14:29:34
|
|
* @FilePath: /CasaOS/pkg/utils/version/version.go
|
|
* @Description:
|
|
* @Website: https://www.casaos.io
|
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
|
*/
|
|
package version
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/IceWhaleTech/CasaOS/model"
|
|
"github.com/IceWhaleTech/CasaOS/types"
|
|
)
|
|
|
|
func IsNeedUpdate(version model.Version) (bool, model.Version) {
|
|
|
|
v1 := strings.Split(version.Version, ".")
|
|
|
|
v2 := strings.Split(types.CURRENTVERSION, ".")
|
|
|
|
for len(v1) < len(v2) {
|
|
v1 = append(v1, "0")
|
|
}
|
|
for len(v2) < len(v1) {
|
|
v2 = append(v2, "0")
|
|
}
|
|
for i := 0; i < len(v1); i++ {
|
|
a, _ := strconv.Atoi(v1[i])
|
|
b, _ := strconv.Atoi(v2[i])
|
|
if i == 0 && a > b {
|
|
continue
|
|
}
|
|
if a > b {
|
|
return true, version
|
|
}
|
|
if a < b {
|
|
return false, version
|
|
}
|
|
}
|
|
return false, version
|
|
}
|