Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Urit
Oct 22, 2010

sarehu posted:

I have a question for you Go people. Suppose you write a web application in Go. What do you do to get it running in actual production?

Right now I ran it with nohup and proxied it with nginx so that it'd run on port 80 after reading a tutorial. I hope it doesn't go down!

But like, seriously, what do you do? This is not really a Go-specific question, sorry that it's in the wrong place.

Yeah, you don't even need nginx really if you want to give it access to lowports.

code:
setcap cap_net_bind_service=+ep /opt/magicalgoadventures/bin/magicalsite
That's the beauty of the whole thing, it's just an executable that runs. It's no different than a completely statically linked C executable. If you're using systemd an example unit file for your Go Web App looks like:

code:
[Unit]
Description=My Wonderful Web App
After=network.target

[Service]
User=nobody
Group=nobody
Type=simple

CapabilityBoundingSet=CAP_NET_BIND_SERVICE

ExecStart=/opt/magicalgoadventures/bin/magicalsite -config=/etc/magicalsite.toml
Restart=always

[Install]
WantedBy=multi-user.target
There's nothing special to do with it other than run it.

Urit fucked around with this message at 03:23 on Mar 15, 2015

Adbot
ADBOT LOVES YOU

Urit
Oct 22, 2010
Is there a consensus on the most viable embedded scripting language for Go? I'm writing something that I'd like to allow (friendly - as in written by internal users and stored on disk with the program) arbitrary code execution in. Lua seems to be vaguely incompatible with Go on Windows due to longjmps for error handling which causes straight up crashes, plus it's playing with CGo. Otto looks neat but it's Javascript which no one wants to write, and it's not really fast for string processing. I found a random project on Github called Agora but it hasn't been maintained for a year and it's somone's toy scripting language, though it looks pretty neat.

Urit
Oct 22, 2010

NickPlowswell posted:

There's
go-lua Which is all native Go so no cgo BS
otto V8 JS all in native Go.

I've used both of them with great success. Pretty decent in terms of performance for what it is, as well.

Pretty much everything else is trash/a toy language that you shouldn't expect users to learn or uses cgo

e: If it matters, I prefer otto. It's much easier to interface with.

Awesome, thanks a ton. Those were the two I saw as well but I was seeing if there was something else out there that was better that I just didn't know about. CGo is cool and all but I'm running in a mixed Windows/Linux environment so the cross-compilation of Go is a huge plus for me, and having to hope that MinGW is going to work today and/or the C portion won't segfault is a pain in the rear end.

Urit
Oct 22, 2010

First Time Caller posted:

Learning Go because we're using Youtube's open source mysql sharding toolset, Vitess. http://www.vitess.io

Really cool poo poo. Why is thread so inactive, go is awesome.

There's not much to post about because all the legitimately cool poo poo is done by Rust and everyone's already argued out Generics etc. The language is so simple that there's not much to talk about especially once you realise it's Google re-inventing Java like Microsoft did with C#.

Urit
Oct 22, 2010

comedyblissoption posted:

Can you elaborate on this? I mainly have experience w/ .NET and am wondering if my preconceived notions of golang would match yours.

Not the person who posted before, but for me coming from .NET I missed generics and class-based inheritance the most plus some stuff feels strangely clunky and you can't do operator overloading. Oh, and there's no such thing as function overloading (e.g. foo(string x) and also foo(string x, int y))

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply