D
D
DDanya2014-04-20 11:56:42
go
DDanya, 2014-04-20 11:56:42

Go + Nginx: teach how to use it correctly

Hello, Happy Easter.
As far as I know, the ideal way to implement a web server in Go is to bundle it with Nginx. And I didn’t really use Nginx before, and then the question arose: what is the best way to access Go, through Proxy or FastCGI? I can’t check at all, since I’m on a Windows working machine. And another very strange question: is it necessary to compile Go with this approach? I just saw a code example somewhere when accessing a source file with a .go extension . Although it is more correct to use a binary. Or am I wrong? Please do not throw stones, I'm just learning how to write websites in Go correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tyranron, 2014-04-20
@DDanya

What is the best way to access Go, through Proxy or FastCGI?

And so and so well. I still prefer the option to proxy requests to Go.
This is not a problem, put a virtual machine and go. In the end: personal experience is better than any explanation.
You need to compile, especially in the case of a large application.
Yes, you can do it:
But, firstly, the code is still compiled into a binary and executed with this approach, it just happens in a folder with temporary files and is kind of hidden from you.
Secondly, this approach does not work if there are more files in the project folder than file.go (meaning at the package main level).
Thirdly, it obliges you to have the appropriate version of Go installed on production servers when the normal binary does not require it.
Fourth, what about daemonization and zero downtime reloads in this case? Yes, you can, but it is inconvenient, given that you will need to recompile each time.
Better to compile once and not bother.
The go run command is more suitable for small files ala script to do one-time work and the like.
Learning is always useful, no one will throw stones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question