Exploring Bash for Windows 10 Pro

By R. S. Doiel 2016-08-15

  1. UPDATE (2016-10-27, RSD): Today trying to compile Go 1.7.3 under
  2. Windows 10 Pro I've am getting compile errors when the
  3. assembler is being built. I can compile go1.4.3 but see errors
  4. in some of the tests results.

Initial Setup and configuration

I am running Windows 10 Pro (64bit) Anniversary edition under Virtual Box. The VM was upgraded from an earlier version of Windows 10 Pro (64bit). The VM was allocated 4G or ram, 200G disc and simulating 2 cores. After the upgrade I took the following steps

Setting up Go under Bash for Windows 10

With Bash installed these are the steps I took to compile Go under Bash on Ubuntu on Windows.

  1. sudo apt-get update && sudo apt-get upgrade -y
  2. sudo apt-get autoremove
  3. sudo apt-get install build-essential clang git-core unzip zip -y
  4. export CGO_ENABLE=0
  5. git clone https://github.com/golang/go go1.4
  6. git clone https://github.com/golang/go go
  7. cd go1.4
  8. git checkout go1.4.3
  9. cd src
  10. ./all.bash
  11. cd
  12. export PATH=$PATH:$HOME/go1.4/bin
  13. cd go
  14. git checkout go1.7
  15. cd src
  16. ./all.bash
  17. cd
  18. export PATH=$HOME/go/bin:$HOME/bin:$PATH
  19. export GOPATH=$HOME

Note some tests failing during compilation in both 1.4.3 and 1.7. They mostly failed around network sockets. This is probably a result of the limitations in the Linux subsystem under Windows.

If successful you should be able to run go version as well as install additional Go based software with the usual go get ... syntax.

In your .bashrc or .profile add the following

  1. export PATH=$HOME/go/bin:$HOME/bin:$PATH
  2. export GOPATH=$HOME

Improved vim setup

I like the vim-go packages for editing Go code in vim. They are easy to setup.

  1. mkdir -p ~/.vim/autoload ~/.vim/bundle
  2. curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
  3. git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go

Example $HOME/.vimrc

  1. execute pathogen#infect()
  2. syntax on
  3. filetype plugin on
  4. set ai
  5. set nu
  6. set smartindent
  7. set tabstop=4
  8. set shiftwidth=4
  9. set expandtab
  10. let &background = ( &background == "dark"? "light" : "dark" )
  11. let g:vim_markdown_folding_disabled=1

Color schemes are browsable at vimcolors.com. They can be installed in $HOME/.vim/colors.

  1. git clone and place the colorscheme
  2. place the *.vim file holding the color scheme into $HOME/.vim/colors
  3. start vim and at the : do colorscheme NAME where NAME is the scheme you want to try

You can find the default shipped color schemes in /usr/share/vim/vimNN/colors where vimNN is the version number e.g. /usr/share/vim/vim74/colors.