You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/08/24 01:49:21 UTC

[GitHub] [openwhisk-runtime-go] style95 commented on a change in pull request #128: Go 1.13 1.14 and 1.15 support with modules, updated examples and documentation.

style95 commented on a change in pull request #128:
URL: https://github.com/apache/openwhisk-runtime-go/pull/128#discussion_r475300773



##########
File path: examples/module-main/go.mod
##########
@@ -0,0 +1,5 @@
+module action
+
+go 1.14

Review comment:
       a nit

##########
File path: docs/BUILD.md
##########
@@ -43,10 +43,11 @@ To build the docker images, after compiling go proxy:
 
 This will build the images:
 
-* `action-golang-v1.11`: an image supporting  Go sources
-* `actionloop`: the base image, supporting generic executables ans shell script
+* `action-golang-v1.13`: an image supporting Go 1.13 sources (does expect an ack)
+* `action-golang-v1.14`: an image supporting Go 1.14 sources (does expect an ack)

Review comment:
       Should we mention v1.15 as well?

##########
File path: docs/ACTION.md
##########
@@ -22,7 +22,7 @@
 
 ## How to write Go Actions
 
-The `action-golang-v1.11` runtime can execute actions written in the Go programming language in OpenWhisk, either precompiled binary or compiling sources on the fly.
+The `action-golang-v1.14` runtime can execute actions written in the Go programming language in OpenWhisk, either precompiled binary or compiling sources on the fly.

Review comment:
       Would it be better to change this to v1.15?

##########
File path: examples/package-main/hello/go.mod
##########
@@ -0,0 +1,3 @@
+module hello
+
+go 1.14

Review comment:
       a nit

##########
File path: examples/EXAMPLES.md
##########
@@ -22,29 +22,24 @@
 This is a collection of examples.
 Tested on:
 
-- dep version 0.5.0 (check the version `dep version`)
-- Go version 1.11.1
+- Go version 1.14.6

Review comment:
       a nit

##########
File path: examples/package-main/go.mod
##########
@@ -0,0 +1,7 @@
+module action
+
+go 1.14

Review comment:
       a nit

##########
File path: docs/DEPLOY.md
##########
@@ -49,120 +49,41 @@ The runtime `action-golang-v1.11` accepts:
 
 Please note in the separate the rules about the name of the main function (that defaults to `main.Main`), and the rules about how to overwrite the `main.main`.
 
-## Using packages and vendor folder
+## Using packages and modules
 
 When you deploy a zip file, you can:
 
 - have all your functions in the `main` package
 - have some functions placed in some packages, like `hello`
 - have some third party dependencies you want to include in your sources
 
-If all your functions are in the main package, just place all your sources in the top level of your zip file
+You can manage those dependencies using appropriate `go.mod` files using relative and absolute references.
 
-### Use a package folder
-
-If some functions belong to a package, like `hello/`, you need to be careful with the layout of your source. The layout supported is the following:
-
-```
-golang-main-package/
-├── Makefile
-└── src
-    ├── hello
-    │   ├── hello.go
-    │   └── hello_test.go
-    └── main.go
-```
-
-You need to use a `src` folder, place the sources that belongs to the main package in the `src` and place sources of your package in the `src/hello` folder.
-
-Then you should import it your subpackage with `import "hello"`.
-Note that this means if you want to compile locally you have to set your GOPATH to parent directory of your `src` packages. Check below for using [VcCode](#vscode) as an editor with this setup.
-
-When you send the image you will have to zip the content
-
-Check the example `golang-main-package` and the associated `Makefile` for an example including also how to deploy and precompile your sources.
-
-### Using vendor folders
-
-When you need to use third part libraries, the runtime does not download them from Internet. You have to provide them,  downloading and placing them using the `vendor` folder mechanism. We are going to show here how to use the vendor folder with the `dep` tool.
-
-*NOTE* the `vendor` folder does not work at the top level, you have to use a `src` folder and a package folder to have also the vendor folder.
-
-If you want for example use the library `github.com/sirupsen/logrus` to manage your logs (a widely used drop-in replacement for the standard `log` package), you have to include it in your source code *in a sub package*.
-
-For example consider you have in the file `src/hello/hello.go` the import:
-
-```go
-import "github.com/sirupsen/logrus"
-```
-
-To create a vendor folder, you need to
-
-- install the [dep](https://github.com/golang/dep) tool
-- cd to the `src/hello` folder (*not* the `src` folder)
-- run `GOPATH=$PWD/../.. dep init` the first time (it will create 2 manifest files `Gopkg.lock` and `Gopkg.toml`) or `dep ensure` if you already have the manifest files.
-
-The layout will be something like this:
+For example you can use a local package `hello` with:
 
 ```
-golang-hello-vendor
-├── Makefile
-└── src
-    ├── hello
-    │   ├── Gopkg.lock
-    │   ├── Gopkg.toml
-    │   ├── hello.go
-    │   ├── hello_test.go
-    │   └── vendor
-    │       ├── github.com/...
-    │       └── golang.org/...
-    └── hello.go
+replace hello => ./hello
 ```
 
-Check the example `golang-hello-vendor`.
-
-Note you do not need to store the `vendor` folder in the version control system as it can be regenerated (only the manifest files), but you need to include the entire vendor folder when you deploy the action.
-
-If you need to use vendor folder in the main package, you need to create a directory `main` and place all the source code that would normally go in the top level, in the `main` folder instead.  A vendor folder in the top level *does not work*.
-
-<a name="vscode">
-
-### Using VsCode
-
-If you are using [VsCode](https://code.visualstudio.com/) as your Go development environment with the [VsCode Go](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go) support, and you want to get rid of errors and have it working properly, you need to configure it to support the suggested:
-
-- you need to have a `src` folder in your source
-- you need either to open the `src` folder as the top level source or add it as a folder in the workspace (not just have it as a subfolder)
-- you need to enable the option `go.inferGopath`
-
-Using this option, the GOPATH will be set to the parent directory of your `src` folder and you will not have errors in your imports.
+Check the example: `package-main` and `module-main` and look for the format of the `go.mod` files.
 
 <a name="precompile"/>
-
 ## Precompiling Go Sources Offline
 
-Compiling sources on the image can take some time when the images is initialized. You can speed up precompiling the sources using the image `action-golang-v1.11` as an offline compiler. You need `docker` for doing that.
+Compiling sources on the image can take some time when the images is initialized. You can speed up precompiling the sources using the image `action-golang-v1.14` as an offline compiler. You need `docker` for doing that.

Review comment:
       Same with above.

##########
File path: golang1.14/Dockerfile
##########
@@ -14,27 +14,28 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-
-IMG?=whisk/action-golang-v1.11
-IMG2?=whisk/actionloop
-
-all: golang bash
-
-test.lua:
-	echo 'wrk.method = "POST"'>test.lua
-	echo "wrk.body = '{\"value\":{\"name\":\"Mike\"}}'">>test.lua
-	echo 'wrk.headers["Content-Type"] = "application/json"'>>test.lua
-
-golang: test.lua
-	docker run -d --name under-test --rm -p 8080:8080 $(IMG)
-	bash init.sh main.go
-	wrk -t1 -c1 -stest.lua http://localhost:8080/run
-	docker kill under-test
-
-bash: test.lua
-	docker run -d --name under-test --rm -p 8080:8080 $(IMG2)
-	bash init.sh main.sh
-	wrk -t1 -c1 -stest.lua http://localhost:8080/run
-	docker kill under-test
-
-.PHONY: all golang bash
+FROM golang:1.13.8

Review comment:
       Should this be some 1.14.x version?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org