我将go_library
srcs 嵌入到 a 中以增强embed.FS
变量。花了一些时间来解决这个问题(参见bazel go_embed_data "could not embed")。
我遇到的新问题是我在运行时收到一个 SIGSEGV 我看到unexpected fault address 0x0
bazel BUILD 和 go 代码如下
go_library(
name = "my_lib",
srcs = ["main.go"],
embedsrcs = glob(["static/**/*"]),
importpath = "github.com/myorg/myrepo",
visibility = ["//visibility:private"],
deps = ["//cmd"],
)
go_binary(
name = "my_linux_amd64",
cgo = True,
embed = [":my_lib"],
gc_goopts = [
"-dynlink",
],
goarch = "amd64",
goos = "linux",
linkmode = "pie",
visibility = ["//visibility:public"],
)
package main
import (
"embed"
)
//go:embed static/*
var staticFS embed.FS // fault address
不知道如何解决这个问题。