简体   繁体   中英

How to run a Go project on Go server?

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.json and main.go . I thought . I thought main.go acts as index.html` or similar.

So, how can I run the project on server?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM