This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UnaryClientInterceptor returns a new unary client interceptor that optionally logs the execution of external gRPC calls. | |
func UnaryClientInterceptor(logger *zap.Logger, opts ...Option) grpc.UnaryClientInterceptor { | |
o := evaluateClientOpt(opts) | |
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { | |
fields := newClientLoggerFields(ctx, method) | |
startTime := time.Now() | |
err := invoker(ctx, method, req, reply, cc, opts...) | |
newCtx := ctxzap.ToContext(ctx, logger.With(fields...)) | |
logFinalClientLine(newCtx, o, startTime, err, "finished client unary call") | |
return err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.5 | |
LABEL maintainer="PercyBolmer@medium" | |
RUN mkdir /app | |
COPY main.go /app | |
WORKDIR /app | |
RUN go build -o helloer . | |
CMD [ "/app/helloer" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"os" | |
"log" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.5 | |
LABEL maintainer="PercyBolmer@medium" | |
#ARG is used during the Image build | |
ARG port=8080 | |
# Assign Environment variabel PORT the value of port. The user running the container can then override this with the -e flag | |
ENV PORT=${port} | |
RUN mkdir /app | |
COPY main.go /app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This compose is for demonstration how to serve our custom image and a prebuilt image | |
version: "3.0" | |
#Services defines what containers to run | |
services: | |
#server is the name for our custom image, this can be anything and is used by other services to refer to this. | |
server: | |
#the image to run the container from | |
image: "learndocker:0.2" | |
# set environments | |
environment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We add as builder to name our build stage. This is needed so that our second build can refer to it | |
FROM golang:1.15 as builder | |
LABEL maintainer="PercyBolmer@medium" | |
#ARG is used during the Image build | |
ARG port=8080 | |
# Assign Environment variabel PORT the value of port. The user running the container can then override this with the -e flag | |
ENV PORT=${port} | |
RUN mkdir /app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.5 | |
LABEL maintainer="PercyBolmer@medium" | |
#ARG is used during the Image build | |
ARG port=8080 | |
# Assign Environment variabel PORT the value of port. The user running the container can then override this with the -e flag | |
ENV PORT=${port} | |
RUN mkdir /app | |
COPY main.go /app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type Human struct { | |
Name string | |
} | |
// This is our method receiver, the type Human receives the Hello method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"errors" | |
) | |
// DateError is a custom error that will fulfill the Error interface | |
type DateError struct { | |
Message string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"errors" | |
) | |
type DateError struct { | |
Message string |