# Windows 10 Golang & WSL2 開發環境筆記 昨天到新公司報到,有點意外,拿到的筆電是 [lenovo thinkpad t14s](https://www.lenovo.com/tw/zh/laptops/thinkpad/thinkpad-t-series/ThinkPad-T14s-AMD-G1/p/22TPT144SA2?cid=tw:sem:s00jpi&gclid=Cj0KCQiAmKiQBhClARIsAKtSj-kIQGg3vYrNygD-nOjOsoSzW0tzMKjQg7KD2XzwLuRdtytSrCVDepwaAqqZEALw_wcB) 雖然是 AMD APU ,但是跟過去開發用的 MBP 還是差很多 >各方面,包括硬體及軟體支援,不得不說 MBP 對開發者來說真的是神器 這邊筆記了整個開發環境的建置及踩坑的過程 ## Docker desktop 在安裝 Docker Desktop for Windows 的過程中,才發現如果用的是家用版,預設是無法安裝的,原因在於新版的 docker for win 是利用 windows 的 Hyper-V 技術,但是這個玩意兒在家用版沒有...所以安裝完後會發生 Docker engine 啟動不能 所幸透過 google 找到了解法: [win10家庭版安裝Docker for Windows](https://www.gushiciku.cn/pl/poUH/zh-tw) 簡單來說就是手動安裝 Hyper-V 必備的套件,之後就可以順利使用 --- ## WSL2 首先要開啟 win 10 相關的服務及應用 [How to Enable WSL 2 on Windows 10](https://www.configserverfirewall.com/windows-10/windows-subsystem-for-linux-2/) 接著要下載 wsl2 的 requirement,主要是參考這篇[較舊版本的 WSL 手動安裝步驟](https://docs.microsoft.com/zh-tw/windows/wsl/install-manual) 直接開啟 Powershell 用 cmd 來執行,比較符合 developer 的精神 ### Systemd 由於 WSL2 是 Windows 下的一個子系統,所以微軟實作了一個 init (PID 1) 來做到快速啓動 WSL VM 以及作為取代 systemd 並與 windows 溝通的橋樑,但這麼一來就沒有 systemd 可用... 所幸 github 上有 repo 可以幫忙處理這一段 :::danger 注意!一旦啟用這個 script,Docker Desktop 內建的 k8s cluster 就沒辦法用了! ::: * [script](https://github.com/DamionGans/ubuntu-wsl2-systemd-script) >安裝完後重啟 wsl 再次進入就可下指令 `ps aux` 觀察 systemd 是否有啟動 :::warning 這邊有踩到一個小坑 因為我先安裝了 zsh,但是腳本預設是執行 bash,所以第一次執行完沒有成功,手動切換到 bash 後再執行一次就好 ::: ### 安裝 zsh + oh-my-zsh + powerlevel10k theme + nerd font * [【分享】Oh My Zsh + powerlevel10k 快速打造好看好用的 command line 環境](https://holychung.medium.com/%E5%88%86%E4%BA%AB-oh-my-zsh-powerlevel10k-%E5%BF%AB%E9%80%9F%E6%89%93%E9%80%A0%E5%A5%BD%E7%9C%8B%E5%A5%BD%E7%94%A8%E7%9A%84-command-line-%E7%92%B0%E5%A2%83-f66846117921) * [p10k custom theme](https://github.com/Holychung/My_Terminal_Theme/tree/main/WSL) * [nerd fonts download](https://www.nerdfonts.com/font-downloads) * [好用插件](https://blog.kwchang0831.dev/blog/dev-env/ubuntu-oh-my-zsh#%E5%AE%89%E8%A3%9D-oh-my-zsh-%E6%8F%92%E4%BB%B6) * [ruby env management : rbenv](https://linuxize.com/post/how-to-install-ruby-on-ubuntu-20-04/) * [非常漂亮的 ls 工具 : colorls](https://github.com/athityakumar/colorls) --- ###### tags: `docker` `Golang` `Linux` `WSL`