New file |
| | |
| | | ``` |
| | | package main |
| | | |
| | | import ( |
| | | "fmt" |
| | | |
| | | "basic.com/valib/licence.git" |
| | | ) |
| | | |
| | | const key = "flzxsqc,ysyhljt." |
| | | |
| | | func main() { |
| | | // 获取机器码 |
| | | machineCode := licence.GetMachineCode() |
| | | |
| | | // 生成Licence |
| | | licenceCode := licence.GenerateLicence(machineCode, "2019-12-12 00:00:00", key) |
| | | |
| | | fmt.Println("machineCode: ", machineCode) |
| | | fmt.Println("licenceCode: ", licenceCode) |
| | | |
| | | // 验证Licence, 0, 成功 1, 无效 2, 设备未授权 3, 过期 |
| | | fmt.Println(licence.VerifyLicence(licenceCode)) |
| | | } |
| | | |
| | | ``` |
| | |
| | | "github.com/shirou/gopsutil/host" |
| | | ) |
| | | |
| | | const key = "flzxsqc,ysyhljt." |
| | | |
| | | type Licence struct { |
| | | MachineCode string |
| | | Expires int64 |