(path string)
| 118 | } |
| 119 | |
| 120 | func updateLib(path string) { |
| 121 | stat, err := os.Stat(path) |
| 122 | fileExists := !os.IsNotExist(err) |
| 123 | if err != nil && fileExists { |
| 124 | panic(err) |
| 125 | } |
| 126 | data, err := getUrl("https://api.github.com/repos/PolyhedraZK/ExpanderCompilerCollection/branches/rust-built-libs") |
| 127 | if err != nil { |
| 128 | if fileExists { |
| 129 | return |
| 130 | } |
| 131 | panic(err) |
| 132 | } |
| 133 | var repoInfo repoInfo |
| 134 | err = json.Unmarshal(data, &repoInfo) |
| 135 | if err != nil { |
| 136 | if fileExists { |
| 137 | return |
| 138 | } |
| 139 | panic(err) |
| 140 | } |
| 141 | remoteTime, err := time.Parse(time.RFC3339, repoInfo.Commit.Commit.Committer.Date) |
| 142 | if err != nil { |
| 143 | if fileExists { |
| 144 | return |
| 145 | } |
| 146 | panic(err) |
| 147 | } |
| 148 | if fileExists { |
| 149 | localTime := stat.ModTime() |
| 150 | if localTime.After(remoteTime) { |
| 151 | return |
| 152 | } |
| 153 | } |
| 154 | downloadLib(path) |
| 155 | } |
| 156 | |
| 157 | func initCompilePtr() { |
| 158 | compilePtrLock.Lock() |
no test coverage detected