Thursday, November 30, 2017

Getting Our Go Apps Up & Running on an MS Windows Workstation

The instructions in the book are geared towards a Mac workstation.

This article is written specifically for readers that use an MS Windows workstation.

Install Go

If you don't already have Go installed, install it.  Here's how:

1. Open your web browser and go to https://golang.org/dl/

2. Click the link for go<VER>.windows-amd64.msi
Note: You may need to run the  go<VER>.windows-386.msi binary if you're running a 32bit Windows system.



3. Install Go

Find the setup program that you downloaded and run it (either double click or right-click | Open).
Click <Run> if you're asked if its' okay to run this software.
Click <Yes> if you're asked if it's okay to allow this software to make changes to your computer.

Click <Next>



Leave the default value (C:\Go\) for Go's installation path.

Click <Next>
Click <Next>
Click <Install>
Click <Finish>

Install Cygwin

If you don't already have Cygwin installed, install it.  Here's how:

1. Open your web browser and go to https://cygwin.com/install.html

2. Click the link for setup-x86_64.exe to install
Note: You may need to run the  setup-x86_64.exe binary if you're running a 32bit Windows system.

3. Install Cygwin

Find the setup program that you downloaded and run it (either double click or right-click | Open).
Click <Run> if you're asked if its' okay to run this software.
Click <Yes> if you're asked if it's okay to allow this software to make changes to your computer.

Click <Next>
Choose "Install from Internet"



Leave default value (C:\cygwin) in Root Directory field
Click <Next>
Leave default value in Local Package Directory (Mine is C:\Users\lex\Downloads)
Click <Next>
Click <Next>
Choose a Download Site  (I chose http://mirror.cs.vt.edu)
Click <Next>
If you see a warning about the current ini file, Click <OK>
If it asks to upgrade, Click <OK>
Install git package  (the version for me was 2.15.0-1)

HEY! Did you follow every one of the 4 steps above?  If not, when you try to run the "git clone" command below it will not work.  1) select "Full" view  2) type git in the Search field  3) click where it says "Skip" on the git: Distributed version control system line.  (it should now say something like "2.15.0-1").  4) click <Next>

Click <Next>(You'll see a Progress window)
If you see "In-use file detected" then click <Stop Process> or <Kill Process>
(You may need to click <Stop Process> or <Kill Process> multiple times)
Eventually, you'll see the "Installation Status" window... Click <Finish>

Now, cygwin and git should be installed.  

Note

You can re-run the cygwin setup.exe as many times as you want to add/remove installed packages.

Get source code for book

1. Double click the Cywing Terminal icon on the Windows desktop
2. Enter the following commands to download this book's source files:

cd
mkdir dev
cd dev
git clone https://github.com/l3x/learn-fp-go


Initialize Windows 

cd
cd dev/learn-fp-go/1-functional-fundamentals/ch01-pure-fp/01_oop/
./init-windows.sh

You'll only need to initialize Windows once.  However, every time you start working on a new Go project you'll want to initialize the Go project with it's init script by typing:  . init

Initialize project and run it 

Before you run the ". init" command below, you should edit the init file.  The tenth line of the file looks like this:

#WIN_GOPATH="E:\\\alice\\\dev\\\learn-fp-go\\\1-functional-fundamentals\\\ch01-pure-fp\\\01_oop"

Edit it to look something like this:

WIN_GOPATH="E:\\\YOUR_USERNAME\\\dev\\\learn-fp-go\\\1-functional-fundamentals\\\ch01-pure-fp\\\01_oop"

If you work off your C drive and your username is bob, it might look like this:

WIN_GOPATH="C:\\\bob\\\dev\\\learn-fp-go\\\1-functional-fundamentals\\\ch01-pure-fp\\\01_oop"

For MS Windows users, for every project, you'll need to edit that line to reflect the current directory.

After you have saved the file, run the following:

. init
go-run

It should return this:  Found &{Model:Highlander}

Initializing other projects and running them

To start the second project, cd into its directory and initialize that project.

cd
cd dev/learn-fp-go/1-functional-fundamentals/ch01-pure-fp/02_fib/
. init
go-run


Glide does not work on Windows in Cygwin 

Here's what'll happen when you try to run glide:

Here's another example:


Bottom line:  If you are using MS Windows, you can run the apps that don't have vendor dependencies using Glide.  In other words, the dot glide-update command will not work for MS Windows.  You must find another way to manage your dependencies.  Probably using the standard way will work.  Here's a video that should help you get setup.


Glide Github Issue Created

I created an issue at the glide github repository.  Hopefully, this issue will be fixed by the time you need it.  For details see this issue.

Uninstall Cygwin

Once you're done working through the applications in this book and if you no longer want Go installed on your workstation, here's how to remove Cygwin.

Open a terminal window and enter the following:
takeown /f C:\cygwin /r /d y
icacls c:\cygwin /t /grant everyone:F
del c:\cygwin

Edit files in Cygwin

You can edit files using the vi editor.


Enter vi init to edit the init file.

You can use your arrow keys to navigate down to line 10 and before you get in insert mode, while the cursor is over the # character, hit the x key.  That will delete the #.  Now, you can right-arrow to move to the end of the line and press the x key to delete the 02_fib characters.  Lastly, press the i key to go into insert mode and then type 01_oop.  Press the Escape key an type :wq to save changes.




2 comments:

  1. Thanks for sharing information about web application development.
    Web Application Development Company in India

    ReplyDelete
  2. Rather, there is no problem with such applications because they all work very well. However, I know that cloud-based native applications are even better. Personally I value IT services like https://grapeup.com/services/application-development/ and I already use some time successfully.

    ReplyDelete