第四章倒数第二节,添加go语言实例
Closed this issue · 2 comments
yihaibin1 commented
dockerfile:
FROM golang:alpine3.15 AS builder
COPY app.go /src/app.go
WORKDIR /src
RUN go build app.go
FROM alpine:3.17.0
COPY --from=builder /src/app /src/app
EXPOSE 8080
CMD ./src/app
golang:
package main
import (
"fmt"
"net/http"
)
func test(w http.ResponseWriter,r *http.Request){
w.Write([]byte("Hello golang"))
}
func main() {
http.HandleFunc("/",test)
err:=http.ListenAndServe(":8080",nil)
if err!=nil{
fmt.Println(err)
}
}
xiaopeng163 commented
can you create a pull request? thanks
Lan-ce-lot commented
I have submitted a PR 👀