Skip to content

Setting Up a Development Environment

Phil Hopper edited this page Nov 19, 2016 · 21 revisions

Install Go (golang) if not already installed

Follow these instruction for Ubuntu/Xubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04.

Note: I used ~/Projects/go as GOPATH.

Get the source code

Download and build Gitea

cd ~/Projects/go
go get code.gitea.io/gitea
cd ~/Projects/go/src/code.gitea.io/gitea
make build

Fork the https://github.com/unfoldingWord-dev/gogs repository into your own github account.

Change origin to unfoldingWord-dev/gogs

cd ~/Projects/go/src/code.gitea.io/gitea
git remote set-url origin https://github.com/unfoldingWord-dev/gogs.git
git fetch --all && git reset --hard origin/master

Note: Do not switch to the develop branch before you have finished the steps above.

Switch to develop branch

git branch --no-track develop refs/remotes/origin/develop
git branch --set-upstream-to=origin/develop develop
git checkout develop

Add your fork as an additional remote

git remote add myfork https://github.com/phillip-hopper/gogs.git

Get the yaml dependency

cd ~/Projects/go
go get gopkg.in/yaml.v2

Create a sym-link to the gogs-custom repository

cd ~/Projects/go/src/code.gitea.io/gitea
ln -s ~/Projects/gogs-custom custom

Configure IntelliJ

Create a new IntelliJ project - New from source

See https://github.com/go-lang-plugin-org/go-lang-idea-plugin/wiki/Documentation.

Add the gitea directory to go libraries for this project

  • File > Settings > Languages & Frameworks > Go > Go Libraries
  • Add ~/Projects/go/src/code.gitea.io/gitea to "Project libraries"

If you get "EditorConfig is overriding code style settings for this file" click OK.

See https://intellij-support.jetbrains.com/hc/en-us/community/posts/207009225-EditorConfig-is-overriding-code-style-settings-for-this-file

Add a run configuration for building and testing

  • Run > Edit configurations
  • Add "Go Application"
  • Name it "Run_Gitea". This is the name IntelliJ will use for the executable, it should be ignored in .gitignore.
  • Run kind = "File"
  • File = "/home/team43/Projects/go/src/code.gitea.io/gitea/main.go"
  • Output directory = "/home/team43/Projects/go/src/code.gitea.io/gitea"
  • Working directory = "/home/team43/Projects/go/src/code.gitea.io/gitea"
  • Program arguments = "web"

You should now be able to run and debug Gitea/Gogs in IntelliJ

Clone this wiki locally