From 8a8483870b0f2e81b684d600053ad2891c6358cc Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Mon, 4 Sep 2023 11:29:49 +0800 Subject: [PATCH] Add support for go --- README.md | 2 +- chsrc.c | 14 ++++---------- chsrc.h | 8 ++++---- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f6e67de..0038b74 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ set # 换源,指定使用某镜像站 - [x] `chsrc set perl` 或 `chsrc set cpan` - [x] `chsrc set php` 或 `chsrc composer` -- [ ] `chsrc set go` +- [x] `chsrc set go` - [ ] `chsrc set rust` 或 `chsrc set cargo` 或 `chsrc crate` - [ ] `chsrc set java` 或 `chsrc set maven` 或 `chsrc set mvn` 或 `chsrc gradle` diff --git a/chsrc.c b/chsrc.c index 5212197..604c62f 100644 --- a/chsrc.c +++ b/chsrc.c @@ -144,8 +144,6 @@ common_cesu_ (source_info* sources, size_t size) for (int i=0;i__bigfile_url; if (NULL==url) { xy_warn ("chsrc: 跳过该站点"); @@ -154,10 +152,9 @@ common_cesu_ (source_info* sources, size_t size) speed = test_speed (url); } speeds[i] = speed; - printf("%d %d\n", i, size); } int fastidx = dblary_maxidx (speeds, size); - xy_success (xy_2strjoin("最快镜像站为: ", sources[fastidx].mirror->name)); + xy_success (xy_2strjoin("chsrc: 最快镜像站: ", sources[fastidx].mirror->name)); return fastidx; } @@ -470,16 +467,13 @@ _pl_go_check_cmd () } } - - -/* TODO: 暂未实现 */ void pl_go_getsrc (char* option) { _pl_go_check_cmd (); - // char* cmd = "npm config get registry"; - // system(cmd); + char* cmd = "go env GOPROXY"; + system(cmd); } /** @@ -948,7 +942,7 @@ target_info pl_nodejs_target = {pl_nodejs_setsrc, NULL, pl_nodejs_sources, pl_nodejs_sources_n}, pl_perl_target = {pl_perl_setsrc, NULL, pl_perl_sources, pl_perl_sources_n}, pl_rust_target = {pl_rust_setsrc, NULL, pl_rust_sources, pl_rust_sources_n}, - pl_go_target = {pl_go_setsrc, NULL, pl_go_sources, pl_go_sources_n}, + pl_go_target = {pl_go_setsrc, pl_go_getsrc, pl_go_sources, pl_go_sources_n}, pl_dotnet_target = {pl_dotnet_setsrc, NULL, pl_dotnet_sources, pl_dotnet_sources_n}, pl_java_target = {pl_java_setsrc, NULL, pl_java_sources, pl_java_sources_n}, pl_php_target = {pl_php_setsrc, pl_php_getsrc, pl_php_sources, pl_php_sources_n}, diff --git a/chsrc.h b/chsrc.h index 8395f1a..7d7e49e 100644 --- a/chsrc.h +++ b/chsrc.h @@ -91,9 +91,11 @@ mirror_info RubyChina = {"rubychina", "RubyChina", "Ruby China 社区", "https://gems.ruby-china.com/", "https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem"}, // 9.9 MB - GoProxyCN = {"goproxy.cn", "Goproxy.cn", "七牛云 Goproxy.cn", "https://goproxy.cn/", NULL}, + GoProxyCN = {"goproxy.cn", "Goproxy.cn", "七牛云 Goproxy.cn", "https://goproxy.cn/", + "https://goproxy.cn/github.com/aws/aws-sdk-go/@v/v1.45.2.zip"}, // 30 MB - GoProxyIO = {"goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/", NULL}, + GoProxyIO = {"goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/", + "https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip"}, // 30 MB NugetOrg = {"nuget.org", "NuGet Org", "Nuget Organization", "https://www.nuget.org/", NULL}; @@ -386,7 +388,6 @@ os_mysys2_sources[] = { int dblary_maxidx(double* array, int size) { - puts("here"); double maxval = array[0]; double maxidx = 0; @@ -396,7 +397,6 @@ dblary_maxidx(double* array, int size) maxidx = i; } } - puts("hello"); return maxidx; }