douxiajiao8445 2015-11-28 04:13
浏览 440
已采纳

如何在Go服务器上运行GO项目?

I'm probably asking super stupid question since 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 fileschat.jsonandmain.go. I thoughtmain.goacts asindex.html` or similar.

So, any idea to how I'm able run the project on server would be appreciated. Thanks.

  • 写回答

2条回答 默认 最新

  • douhuan1937 2015-11-28 13:42
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?