Nadeem Afana's Blog Home
Time 2021-10-11 07:06:32Web Name: Nadeem Afana's Blog Home
WebSite: http://afana.me
ID:201172
Keywords:
Afana,Nadeem,Home,Blog,Description:
keywords: description:Home Nadeem Afana2019. All rights reserved.
Save Disk Space By Installing Golang in the Same Folder on Windows and WSL 30 Oct 2019 · CommentsI used to use Git for Windows before, but then I switched to WSL after it came out. I find WSL faster and has some advantages such as packaging tools (eg APT). I use GO on both Windows and WSL for development, and the last time I looked at the disk space usage of its packages, I saw
$ du -hs $HOME/go1.1G /home/nadeem/go
for Linux and another similar number for Windows. This number keeps growing over time. GO as you know relies on package source code and not binaries when building projects, and thus caches packages source code on disk for later use. The packages between Windows and Linux are the same. This sounds like a waste of disk space. I decided to combine both folders into one, and so far I have not had any issues.
The following steps describe how to do so:
InstallGO
on Windows by following the online instructions. Open the command prompt as an admin and add permissions to your user AB\nadeem
. This is needed to copy files from within WSL: icacls "C:\go" /grant AB\nadeem:F /T
where C:\go
is where GO was installed on Windows.
goX.XX.X.linux-amd64.tar.gz
) and then extract it into the same folder C:\go
skipping existing files: tar --skip-old-files -C '/mnt/c/go/' -xzf /tmp/go1.12.9.linux-amd64.tar.gz
If you had installed GO on WSL before then remove its folders. Mount the package folder $HOME/go
to point to C:\users\nadeem\go
sudo mount -v --bind /mnt/c/users/nadeem/go /home/nadeem/go
Make the mount persist by updating /etc/fstab
: /home/nadeem/go /mnt/c/users/nadeem/go rw bind,metadata 0 0
Add go
bin to the PATH
if needed. export PATH=$PATH:"/mnt/c/go/bin"
Verify all the steps worked by building an app from both WSL and Windows: In WSL: mkdir hello-go cd hello-go
Save the following code into a file called hello.go
package main import "fmt" func main() { fmt.Printf("hello, world\n") }
Run the following in WSL:
go mod init hello go build hello.go ./hello
Now in a Command prompt window run:
cd hello-go go build hello.go hello
If you list the files under hello-go
folder, you’ll see two binaries: The one generated in Windows and the other one in WSL.
dir 10/30/2019 03:58 PM 22 go.mod 10/30/2019 04:01 PM 2,010,168 hello 10/30/2019 04:01 PM 2,075,648 hello.exe 10/30/2019 03:58 PM 97 hello.go
Conclusion The package folder used by GO can be enormous and grows over time. Installing GO on both Windows and WSL can be convenient but leads to duplicate disk space usage. This space can be shared between Windows and WSL by installing both to the same folder on disk.
Comments Older Newer<<< Thank you for your visit >>>
HomeWebsites to related : Big Brown Bear
keywords:
description:Free typing games and phonics resources.
Big Brown Bear
keywords:
description:
Call Today!
(708) 396-1090
(708) 945-2705
keywords:
description:
keywords:
description:
首页 学术资源 学科导航 学者空间 机构空间 专题 期刊| 学位论文|
keywords:Shabab Crazy, Welcom, To, Shabab, Crazy, This Website Made By GIGQ
description:Welcome To shabab crazyThis Website Made By GIGQ اهلا وس
keywords:depth filters, depth filtration, oliefiltre, oliepleje, offline fine filters, oil filters, water-oil separation, oil filtration, clean oil, d
| 上海昌为医药辅料技术有限公司 | keywords:| 药用辅料,崩解剂,粘合剂,润滑剂,填充剂
description:上海昌为专注进口高品质药用辅料
keywords:
description:In-person football coaching clinics in 22 U.S. cities. Year-round online education on Glazier Drive. Glazier provides the best i
keywords:web hosting, provider, php hosting,web hosting, free domain names, domain name, front page hosting, web site, web design, domain name registr
Verines.com - Venta de Materialekeywords:PAVECA, Articulos, Productos de Limpieza, Servilletas, Papel Higienico, Toallas, Vasos, Coletos, Paños Amarillos, Araganes, Cloro, Mayor y D
adsHot Websites