News for hackers. Stuff that matters.
Re:Caddy 0.9 Released with All New Core by embik on Tuesday July 19, 2016 @03:34AM (#12120359)
The one thing that bothers me (which is not Caddy's fault at all) is the plugin system. If I understand correctly, I have to recompile Caddy for every plugin I want to use, right? Sounds like a limitation with Go which is really unfortunate.
Re:Caddy 0.9 Released with All New Core by thwd on Tuesday July 19, 2016 @03:54AM (#12120446)
Compiling a Go program is really quick and painless! Nothing like a similar C/C++ project.
Re:Caddy 0.9 Released with All New Core by embik on Tuesday July 19, 2016 @04:49AM (#12120623)
I'm a Gentoo user myself so from a personal perspective I don't see any problem, but in a professional environment it's another thing I have to do - Install (and update) Go from somewhere because it's obviously not in the CentOS repositories (at least in an acceptable version), set up a build process and make sure to build updated versions, etc. Just dropping in libraries into some directory to be loaded as plugin would be arguably easier and is kinda "standard" for plugin systems.
Re:Caddy 0.9 Released with All New Core by fahrradflucht on Tuesday July 19, 2016 @09:12AM (#12121508)
I use Caddy on CentOS for quite a while. There is a Repo on Copr that let's you install it minimal or with plug-ins and it works just you would expect.
Re:Caddy 0.9 Released with All New Core by xena on Tuesday July 19, 2016 @02:14PM (#12123618)
Do you mean this copr[1]? I just pushed the 0.9 update.

[1]: https://copr.fedorainfracloud.org/coprs/xena/caddy/

Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @08:05AM (#12121215)
It is not a Go limitation, rather a toolchain one.

Dynamic linking support was introduced in version 1.5, but it only works in GNU/Linux currently.

I expect it to eventually be available in all target OSes.

Re:Caddy 0.9 Released with All New Core by kureikain on Tuesday July 19, 2016 @03:40AM (#12120391)
Isn't that the same for Nginx? You still have to compile when you add new plugin?

Caddy is very easy to use. You can download the build with what you want from their download page.

The nicest thing about it is very simple config file, TLS out of the box, automatically renew as well.

Re:Caddy 0.9 Released with All New Core by pilif on Tuesday July 19, 2016 @03:42AM (#12120400)
>Isn't that the same for Nginx? You still have to compile when you add new plugin?

nope. That has been fixed with recent development versions that support loading plugins as shared libraries. For distros, that's very important because it allows them to ship much more configurable nginx packages as now plugins can be added as-needed.

Re:Caddy 0.9 Released with All New Core by Nullabillity on Tuesday July 19, 2016 @05:32AM (#12120775)
I'm not a big fan of this either. Now you need to keep track separately of what your snowflake build enables, and when it's time to update, or if you want to add something else, then you need to go back and fill out the form manually again, and update manually.

Also, it makes distro packaging dreadful, since you can either ship nothing and be useless for nearly everyone, or ship everything and surprise users if they switch to the official builds and find out stuff is missing.

Nginx used to be as bad, but that's been fixed recently.

Personally Caddy is also not very useful for me, since I use a reverse proxy, and Caddy didn't seem very helpful there the last time I tried. Oh, and it would have been nice to be able to make it generate self-signed certificates for staging environments.

Re:Caddy 0.9 Released with All New Core by cuu508 on Tuesday July 19, 2016 @07:09AM (#12121028)
What problems did you have with reverse proxying?

The article says 0.9 can now generate self-signed certificates like so

    tls self_signed
Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @04:39AM (#12120591)
Go does not allow dynamic library loading. So either your plugin system have to be backed by a third party language that has a interpreter/vm/whatever coded in Go, or you have to rely on some RPC method of some kind. So yeah it's a huge limitation with Go that makes it just unsuitable for a wide range of use cases.
Re:Caddy 0.9 Released with All New Core by vetinari on Tuesday July 19, 2016 @06:55AM (#12120986)
Go does allow for consuming dynamically linked libraries, but it's not that simple as with C. For example, you have probably seen OpenGL bindings for Go - that's one of these things that would not work without dynamic linking.

The issue is, that Go runtime has it's own ideas how the memory layout and stack layout should look like and these ideas are not compatible with __stdcall or __cdecl, so when calling C code, the runtime has to do a clean up. That used to involve a thread switch, now it involves a full register swap.

What Go does not allow, is putting Go code into dynamic library and then calling that from another go application - i.e. native go plugins for go apps.

Re:Caddy 0.9 Released with All New Core by icebraining on Tuesday July 19, 2016 @07:23AM (#12121066)
What Go does not allow, is putting Go code into dynamic library and then calling that from another go application - i.e. native go plugins for go apps.

Since Go allows you to call C libraries, and allows you to write C libraries, couldn't you write a Go program that loaded a Go library but just talked over a C-style API?

Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @10:50AM (#12122105)
> Since Go allows you to call C libraries, and allows you to write C libraries, couldn't you write a Go program that loaded a Go library but just talked over a C-style API?

It would be like writing a Go interpreter in C. Pointless.

Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @10:49AM (#12122094)
> What Go does not allow, is putting Go code into dynamic library and then calling that from another go application - i.e. native go plugins for go apps.

That's exactly what I said, you're talking about dynamic linking not dynamic library loading.

Re:Caddy 0.9 Released with All New Core by vetinari on Tuesday July 19, 2016 @11:03AM (#12122168)
It allows dynamic loading, but only C code, not Go code. You can do dlopen()/LoadLibrary() and then dlsym()/GetProcAddress(), but only with C calling convention.
Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @11:18AM (#12122253)
> It allows dynamic loading, but only C code, not Go code. You can do dlopen()/LoadLibrary() and then dlsym()/GetProcAddress(), but only with C calling convention.

That's a C feature not a Go one. You still can't do that ie calling a Go compiled library from a Go executable AT run time, like one can load JAR and execute some Java code from a Java program at runtime. Because the language doesn't allow that.

No matter how you people try to spin that thing this is impossible to do with Go directly. Period. Using C involves a crazy overhead and complexity which is absolutely not worth it.

Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @08:04AM (#12121211)
> What Go does not allow, is putting Go code into dynamic library and then calling that from another go application - i.e. native go plugins for go apps.

Yes it does, since version 1.5, but the toolchain doesn't support it yet across all supported targets.

Re:Caddy 0.9 Released with All New Core by vetinari on Tuesday July 19, 2016 @10:11AM (#12121861)
Do you mean -buildmode=shared and -linkshared for linux/amd64?

Don't you have to link the executable explicitly with the shared libraries? I.e. no dlopen()-like plugins?

Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @10:36AM (#12122019)
Yeah something like that.

Not sure how it exactly works, I just happen to still follow Go every once in a while.

I see it as a good C replacement for many use cases that don't really need C as portable Assembler features.

So from the gonuts discussions and design documents, I assume that at least on GNU/Linux systems it is already possible.

Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @08:03AM (#12121205)
Yes it does, but the toolchain support is not yet available for all operating systems.

    go build -buildmode=c-shared
Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @10:48AM (#12122090)
No it doesn't. How can you open dynamically a third party Go library from your Go binary ? you can't.
Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @11:53AM (#12122439)
So what is that supposed to do?
Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @12:20PM (#12122617)
What is a JAR loaded at runtime in Java code supposed to do ?
Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @01:07PM (#12123013)
Well I expect it to work like this:

- Define a Go interface for plugin

- Create a C style shared library with a factory function

- On the application side, load the library and cast the pointer to the plugin interface

- Make sure the Go runtime is compiled as a shared library visible to the application and respective plugins

It is as easy to put a jar into a directory? No, but it is doable.

Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @04:13PM (#12124501)
> Create a C style shared library with a factory function

> On the application side, load the library

Show me the code then, I still maintain than what you think is possible isn't. And I don't want to see any C code in your example.

Re:Caddy 0.9 Released with All New Core by pjmlp on Tuesday July 19, 2016 @04:44PM (#12124749)
I might try to do it as a learning exercise of the state of Go tooling, but I have better things with my life than proving things to strangers on the Internet.
Re:Caddy 0.9 Released with All New Core by spriggan3 on Tuesday July 19, 2016 @05:18PM (#12124993)
Sure, and you can make up anything without facts. I have also better things to do that believing a complete stranger which can't source his claims.