Skip to content

Commit 1a6f127

Browse files
zephylacPierre Champion
authored and
Pierre Champion
committed
Support Chinese URL (#48)
Fixes #48
1 parent c42c104 commit 1a6f127

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

example/simpleDemo/engineDownloader.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"archive/zip"
55
"bufio"
66
"encoding/json"
7+
"flag"
78
"fmt"
89
"io"
910
"io/ioutil"
@@ -202,6 +203,18 @@ func downloadFile(filepath string, url string) error {
202203
}
203204

204205
func main() {
206+
// Support flag
207+
chinaPtr := flag.Bool("china", false, "Whether or not installation is in China")
208+
flag.Parse()
209+
var targetedDomain = ""
210+
211+
// If flag china is passse, targeted domain is changed (China partially blocking google)
212+
if *chinaPtr {
213+
targetedDomain = "https://storage.flutter-io.cn"
214+
} else {
215+
targetedDomain = "https://storage.googleapis.com"
216+
}
217+
205218
// Execute flutter command to retrieve the version
206219
out, err := exec.Command("flutter", "--version").Output()
207220
if err != nil {
@@ -260,24 +273,24 @@ func main() {
260273
switch runtime.GOOS {
261274
case "darwin":
262275
platform = "darwin-x64"
263-
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform)
276+
downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform)
264277
endMessage = "export CGO_LDFLAGS=\"-F${PWD} -Wl,-rpath,@executable_path\""
265278

266279
case "linux":
267280
platform = "linux-x64"
268-
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
281+
downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
269282
endMessage = "export CGO_LDFLAGS=\"-L${PWD}\""
270283

271284
case "windows":
272285
platform = "windows-x64"
273-
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder.zip", hashResponse.Items[0].Sha, platform, platform)
286+
downloadShareLibraryURL = fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
274287
endMessage = "set CGO_LDFLAGS=-L%cd%"
275288

276289
default:
277290
log.Fatal("OS not supported")
278291
}
279292

280-
downloadIcudtlURL := fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform)
293+
downloadIcudtlURL := fmt.Sprintf(targetedDomain+"/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform)
281294

282295
err3 := downloadFile(dir+"/.build/temp.zip", downloadShareLibraryURL)
283296
if err3 != nil {

0 commit comments

Comments
 (0)