Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Go version #2

Closed
wants to merge 1 commit into from
Closed

update Go version #2

wants to merge 1 commit into from

Conversation

mom0tomo
Copy link
Owner

@mom0tomo mom0tomo commented Dec 9, 2022

I have updated Go to 1.19 (the latest version as of 2022/12) and also updated the README.


Goを1.19(2022/12時点の最新版)に更新しました。READMEも更新しました。

```
$ GOOS=linux GOARCH=amd64 go build github.com/livesense-inc/fanlin/cmd/fanlin
$ CGO_ENABLED=1 CC="x86_64-linux-musl-gcc" GOOS=linux go build github.com/livesense-inc/fanlin/cmd/fanlin
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved livesense-inc#33.

You are cross-compiling from Darwin to Linux with CGO_ENABLED=1. That requires setting CC to a cross-compiler that generates Linux objects using Linux header files.

ref: golang/go#54695

@mom0tomo
Copy link
Owner Author

既存のバイナリとサイズが大きく異なる。
また何らかの原因でバイナリを実行するとエラーになる。

$ ls -lth backup/fanlin
-rw-r--r--@ 1 momo.watanabe  staff    23M 12 15 16:03 s3/fanlin
$ ls -lth fanlin
-rwxr-xr-x  1 momo.watanabe  staff    15M 12 15 16:02 fanlin*

@mom0tomo
Copy link
Owner Author

バイナリサイズはGoのバージョンアップのおかげだった。問題ではない。
クロスコンパイルしたバイナリは実機(Ubuntu)上でエラーになるが、Dockerを使ってビルドしたものは同じサイズで通常通り動作する。

Dockerfile

FROM ubuntu:20.04
USER root

WORKDIR /usr/local

RUN apt-get update && apt upgrade
RUN apt-get install -y wget git mercurial
RUN wget https://go.dev/dl/go1.19.4.linux-amd64.tar.gz
RUN tar xvzf go1.19.4.linux-amd64.tar.gz
RUN rm go1.19.4.linux-amd64.tar.gz

RUN apt-get install -y gcc

ENV PATH /root/go/bin:/usr/local/go/bin:$PATH

@mom0tomo mom0tomo closed this Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant