How to run a Go project on Go server?

17.7k views Asked by At

I have no experience on GoLang.

I have a Go project and I want to run it on my local server on my ubuntu 14.04. I have installed Go server and Go agent and they are running.

hesam: ~ $ sudo /etc/init.d/go-server start
[sudo] password for hesam: 
using default settings from /etc/default/go-server
Started Go Server on http://hesam:8153/go
hesam: ~ $ sudo /etc/init.d/go-agent start
[Fri Nov 27 20:46:44 MST 2015] using default settings from /etc/default/go-agent
Started Go Agent.
hesam: ~ $

Based on what command line said /var/go/ is the folder that I can use to put my GO project inside. Based on what I know in Apache server there is www folder that we will have access to from localhost. So, I'm expecting something like this with Go server (but seems I'm wrong).

My project contains some folders such as client, config, protocol, server' and two files chat.jsonandmain.go. I thought main.goacts asindex.html` or similar.

So, how can I run the project on server?

2

There are 2 answers

2
Markus W Mahlberg On BEST ANSWER

The go-server and go-agent are part of the Go continuous delivery system and are absolutely not needed to run a program written in the Go programming language.

Actually, you don't need anything to run a compiled program written in Go, since it is statically compiled (by default, dynamic linking available), meaning that all necessary libraries are put into the executable itself and the executable is self sufficient (within certain limits, but that is an edge case, here).

So in order to run a Go program, just build it and call it like

$ /path/to/programName
Hello, World!

(assuming you build the classical example).

Please see How to Write Go Code for details.

0
sfault On

To run a golang program you can either do go run or go install. If you haven't setup go environment you can use gvm or on linux distro install using package manager.