2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GO環境でcould not import Cエラー

Last updated at Posted at 2020-11-23

エラー発生

Goのgraphqlライブラリのgqlgenでスキーマを更新しようとしたら謎のエラー

/go/src # go run github.com/99designs/gqlgen
validation failed: packages.Load: /usr/local/go/src/net/cgo_linux.go:12:8: could not import C (no metadata for C)
exit status 1

解決

どうやらgccがdockerイメージ上に入ってない模様。
たぶんきっとこれ? https://github.com/golangci/golangci-lint/issues/602

apk updateしてapkをアップデートした後、alpine-sdkというビルドパッケージ?を入れたらうまく行きました。
apkについては、この記事が分かりやすかったです。

/go/src # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz

fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.1-44-g754f23ac8f [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.1-41-g42f619918d [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12746 distinct packages available
/go/src # apk add alpine-sdk
(1/37) Upgrading musl (1.1.24-r9 -> 1.1.24-r10)
  0%                                                                                                                                                                                                                   
(2/37) Installing fakeroot (1.24-r0)
(3/37) Installing openssl (1.1.1g-r0)
(4/37) Installing libattr (2.4.48-r0)
(5/37) Installing attr (2.4.48-r0)
(6/37) Installing libacl (2.2.53-r0)
(7/37) Installing tar (1.32-r1)
(8/37) Installing pkgconf (1.7.2-r0)
(9/37) Installing patch (2.7.6-r6)
(10/37) Installing libgcc (9.3.0-r2)
(11/37) Installing libstdc++ (9.3.0-r2)
(12/37) Installing lzip (1.21-r0)
(13/37) Installing nghttp2-libs (1.41.0-r0)
(14/37) Installing libcurl (7.69.1-r1)
(15/37) Installing curl (7.69.1-r1)
(16/37) Installing abuild (3.6.0-r1)
Executing abuild-3.6.0-r1.pre-install
(17/37) Installing binutils (2.34-r1)
(18/37) Installing libmagic (5.38-r0)
(19/37) Installing file (5.38-r0)
(20/37) Installing gmp (6.2.0-r0)
(21/37) Installing isl (0.18-r0)
(22/37) Installing libgomp (9.3.0-r2)
(23/37) Installing libatomic (9.3.0-r2)
(24/37) Installing libgphobos (9.3.0-r2)
(25/37) Installing mpfr4 (4.0.2-r4)
(26/37) Installing mpc1 (1.1.0-r1)
(27/37) Installing gcc (9.3.0-r2)
(28/37) Installing musl-dev (1.1.24-r10)
(29/37) Installing libc-dev (0.7.2-r3)
(30/37) Installing g++ (9.3.0-r2)
(31/37) Installing make (4.3-r0)
(32/37) Installing fortify-headers (1.1-r0)
(33/37) Installing build-base (0.5-r2)
(34/37) Installing expat (2.2.9-r1)
(35/37) Installing pcre2 (10.35-r0)
(36/37) Installing git (2.26.2-r0)
(37/37) Installing alpine-sdk (1.0-r0)
Executing busybox-1.31.1-r19.trigger
OK: 224 MiB in 51 packages

ひとりごと

使っているdockerイメージgolang:1.15.5-alpine3.12がいけなかったのか。。
詳しい方教えてください>_<

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?