Skip to content

Commit 23db8b3

Browse files
committed
Update ordering of GO_REPLACE statements
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 8bb365f commit 23db8b3

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func Handle(w http.ResponseWriter, r *http.Request) {
304304

305305
For this example you will need to be using Go 1.13 or newer and Go modules, enable this via `faas-cli build --build-arg GO111MODULE=on`.
306306

307-
Imagine you have a package which you want to store outside of the `handler.go` file, it's another middleware which can perform an echo.
307+
Imagine you have a package which you want to store outside of the `handler.go` file, it's another middleware which can perform an echo of the user's input.
308308

309309
```Golang
310310
package handlers
@@ -315,26 +315,25 @@ import (
315315
)
316316

317317
func Echo(w http.ResponseWriter, r *http.Request) {
318-
319318
if r.Body != nil {
320319
defer r.Body.Close()
321320
b, _ := ioutil.ReadAll(r.Body)
322321
w.Write(b)
323322
}
324-
325323
}
326324
```
327325

328-
To include a relative module such as this new `handlers` package, you should create a `GO_REPLACE.txt` file as follows.
329-
330-
Let's say your GOPATH for your GitHub repo is: `github.com/alexellis/vault/` and your OpenFaaS function is `purchase` generated by `faas-cli new purchase --lang golang-middleware`.
331-
332-
Your relative GOPATH is: `github.com/alexellis/vault/purchase`, so add a redirect as per below to redirect the "handlers" package to where it exists in the build container.
326+
To include a relative module such as this new `handlers` package, you should create a `GO_REPLACE.txt` file as follows:
333327

334328
```
335329
replace github.com/alexellis/vault/purchase/handlers => ./function/handlers
336330
```
337331

332+
How did we get to that? Let's say your GOPATH for your GitHub repo is: `github.com/alexellis/vault/` and your OpenFaaS function is `purchase` generated by `faas-cli new purchase --lang golang-middleware`.
333+
334+
Your relative GOPATH is: `github.com/alexellis/vault/purchase`, so add a redirect as per below to redirect the "handlers" package to where it exists in the build container.
335+
336+
338337
Now if you want to reference the handlers package from within your `handler.go` write the following:
339338

340339
```golang

0 commit comments

Comments
 (0)