Contents Page Previous Next

The Goblimey Scaffolder

2.1 Creating a Project

The scaffolder generates Go source code. Go source code is stored in a project directory, so you need to create one of those. As the How to Write Go Code document explains, you should structure your project as if you are going to store it in a repository. The Github is the most popular repository so I'm going to assume that you will store it there.

If you are absolutely convinced that you are not going to store your project in a repository, then you just need to create a directory in the src directory of your go project directory (so in my case, that might be /home/simon/goprojects/src/animals).

DO NOT create a project on your computer and try to store it on the github later. It's much easier to start with a github project and then clone a copy of it on your computer. So the next thing to do is create a github project.

If you don't have a Github account, create one at github.com. It's free. For example, if your name is Alun Smithie, you could create an account called alunsmithie. Your home page on the github would then be https://github.com/alunsmithie. I'm going to assume that in the following examples, so replace "alunsmithie" with your github account name.

Back on your computer, create subdirectories in your goprojects directory matching the github structure (so in this example src/github.com/alunsmithie) and change directory to it.

In a Linux command window:


    $ mkdir -p $GOPATH/src/github.com/alunsmithie
    $ cd $GOPATH/src/github.com/alunsmithie
   
On Windows:

    mkdir %GOPATH%\src
    mkdir %GOPATH%\src\github.com
    mkdir %GOPATH%\src\github.com\alunsmithie
    cd %GOPATH%\src\github.com\alunsmithie
    

On your github home page, use the "+" button at the top to create a project. If you call your projects "animals", it will have a URL something like https://github.com/alunsmithie/animals.

When you create your project, the Github will encourage you to specify what sort of licence you will issue when you publish it, and to set up a README.md file describing what the project is about. (The README.md for the scaffolder project is here. Most of it is created automatically by the github.)

Now you can clone your github project in your command window. It's the same command on Linux and Windows.


     git clone https://github.com/alunsmithie/animals
   

That creates a directory "animals" containing a copy of any files you created on the github site - the README.md and the license file. It also contains some magic hidden files that make it a local git repository.

Contents Page Previous Next