package main

import (
    "fmt"

    "github.com/tealeg/xlsx"
)

func main() {
    xlFile, err := xlsx.OpenFile("Item.xlsx")
    if err != nil {
        panic(err.Error())
    }

    for _, v := range xlFile.Sheets[0].Rows {
        if len(v.Cells) > 0 {
            fmt.Printf("%s %s\n", v.Cells[1].String(), v.Cells[0].String())
        }
    }
}

使用 docker 的 multistage 就可以实现在docker镜像中编译golang程序,并打包可执行为镜像。

FROM golang:1.15-alpine AS builder
WORKDIR /workspace
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

# src code
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64  go build -o main ./cmd/server

FROM alpine:3.12
COPY --from=builder /workspace/main /main
RUN chmod +x /main
ENV TZ=Asia/Shanghai
ENTRYPOINT ["/main"]

参考资料:
https://segmentfault.com/a/1190000039727679

默认是从 unpkg.js 中加载的可以通过设置常量参数来修改加载路径。

flutter build web --dart-define=FLUTTER_WEB_CANVASKIT_URL=/
表示从当前根目录加载,会加载 canvaskit.js canvaskit.wasm

只有在编译模式下才会生效

const VERSION = String.fromEnvironment('VERSION', 'v0.0.0'); // 切记!!必须是常量类型才能替换
const PLATFORM = String.fromEnvironment('PLATFORM', 'android');

main() {
    print("VERSION: " + VERSION);
    print(const String.fromEnvironment('PLATFORM', 'android')); // 以常量形式访问
}

dart compile exe -DVERSION=v1.0.1 -DPLATFORM=android main.dart
dart -DVERSION=v1.0.1 -DPLATFORM=android main.dart
flutter build web --dart-define=VERSION=v1.0.1 --dart-define=PLATFORM=android