About  -main "foo.Bar" there are 2 problems doing that.

First thing, I need to "capitalize" the main function name.  So "--main main"  
means "Main" in package "main"

Why? Because In Go there is only one main in package main with signature "()" 
and I need to use it for the "startup" code.

So I have use either another name or "main" another package. But if I use for 
example "main" in another package... I have the problem that whatever function 
I use it must be capitalized anyway because that is the Go way to say "public". 
 Initially it was "action.Main" the I decided that just leaving in "main" 
package was fine no need to specify an arbitrary package. Also because usually 
files in "main" package are left in the root while other packages are in 
subdirectories.

So the simplest solution it to interpret "main" as "main.Main" and "hello" and 
"main.Hello".

Is it possible to use "-main package.function" ? Well it is but... 

1. I would need to split "package" and "function" then capitalize to "Function" 
and interpret as "package.Function" (because for sure Package.function is NOT 
going to work..."
2. in the startup code I do not have only to replace the function name but also 
add "import "package"" somewhere.

Not sure it is worth the effort because it is pretty ease to write a function 
in main package that will forward to whatever entry point in inner packages we 
may want.


If you have better ideas they are welcome.

-- 
  Michele Sciabarra
  [email protected]

----- Original message -----
From: Rob Allen <[email protected]>
To: [email protected]
Subject: Re: Interpretation of "main" for GoLang and ActionLoop docker images
Date: Sun, 30 Sep 2018 21:38:49 +0100

Hi Michele,

>From a someone who doesn't use Go, this all seems sensible and predictable to 
>me, though I have one question that may show my lack of knowledge of the 
>language!

> Case4: sending a zip with source actions. Here is where the current rules 
> turned out to be very confusing. So I am going to simplify this way:
> 
> You can upload all the files you want in your zip file, they must all have 
> .go extension and they will be compiled. You must NOT have a main.main 
> function as this will be provided by the runtime. The name of the main 
> function will be interpreted as in 3: -main main (or default) => main.Main , 
> -main hello => main.Hello


Does this mean that I can't specify a different module other than main for 
entry point? e.g. would  -main foo.Bar work and result in the Bar function in 
the foo package being the entry point to the action?

This is on my mind as I'm considering updating the PHP (and Python?) runtimes 
to support setting the file as well as the function name and would use the 
format -name foo.php:bar to run the bar() function in foo.php as the entry 
point. (Currently, the filename is hardcoded to index.php).

Regards

Rob




> On 29 Sep 2018, at 09:03, Michele Sciabarra <[email protected]> wrote:
> 
> Hello all,
> 
> I need to discuss my plan for simplifying rules for interpreting "main" for 
> Golang. 
> 
> The rules I have used for interpreting the "main" parameter in wsk turned out 
> to be a bit confusing, so I plan to make them simpler. This is what I plan to 
> implement, please confirm it is fine OR tell me if there is something I 
> should change. The text below will go in documentation if it is ok.
> 
> ----
[snip]

-- 
Development thoughts at http://akrabat.com
Daily Jotter for macOS at http://dailyjotter.com

Reply via email to