Running multiple Go applications using only port :80


Running multiple Go applications using only port :80

Assuming I want to open only a single port on my server.

How would I run multiple Go applications?

From what I understand I can't really use a reverse proxy on port :80 because that still requires that the Go applications have their own ports.

Or is there a way to open a port without exposing it to the rest of the internet (just for local use)?

Submitted February 11, 2017 at 11:31PM by DanChm
via reddit http://ift.tt/2kx8Hkp

why delete() doesn’t return a bool ?


why delete() doesn’t return a bool ?

The bultin function delete() removes an element from a map if the element is present. But delete() doesn't tell us if the element was present or not.

So when I want to remove an element form a map and need to report an error if it wasn't present, I need to write the following:

if _, ok := m[key]; !ok { return errors.New("element is missing") } delete(m, key) 

If delete() returned a bool set to true if an element with the corresponding key was found and deleted, I could write this:

if !delete(m, key) { return errors.New("element is missing") } 

The difference is that with the former code I need two map lookup, and the later code, I need only one.

People who don't care if the element is there or not when deleting the element could simply ignore the return value.

Is there a reason why delete doesn't return a bool ? It could also extract the value from the map and return it with the bool.

Submitted February 11, 2017 at 11:40PM by chmikes
via reddit http://ift.tt/2keDrKN

Want to see if I get it right: Data-data relationships


Want to see if I get it right: Data-data relationships

While I get pure functions and type classes, I'm still not sure about how to abstract relationship between data.

Let's say I have a Person

data Person = Person { name :: String, age :: Int } 

and now I want to model followership (like e.g. in Twitter, i.e. a 1-n relation). I can now think of two things:

I could rewrite the data constructor like so:

data Person = Person { name :: String, age :: Int, following :: [Person]} 

Or I could create a new object, which models this relationship:

followership :: [(Person, [Person])] 

And create some useful operations for that with lookup. Which would be idiomatic Haskell?

Submitted February 11, 2017 at 09:49PM by hgiesel
via reddit http://ift.tt/2kTvEiD

Can’t get this to work :/


Can’t get this to work :/

Hey everyone, I'm building a website and currently need to get a plugin working. The plugins uses code to make a iframe in a fancybox.

The code I need to get working is : If I click on the menu item (51) it needs to execute this script, yet it only gives errors.

$('.menu-item-51').click(function() { <?php iframepopup( $id = "3", $category = "Category1" ); ?> }); 

Here is the plugin documentation where the PHP part is from

Can anyone help me with this?

I have tried fixing it with JSHint but I can't get it to work.

It's currently throwing

Uncaught SyntaxError: Unexpected token < 

Submitted February 11, 2017 at 09:06PM by Hoekynl
via reddit http://ift.tt/2lA1joE