学习fyne过程中,发现示例执行报错,四处查询后采用添加环境变量解决。
程序
package main
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Hello")
hello := widget.NewLabel("Hello Fyne!")
w.SetContent(container.NewVBox(
hello,
widget.NewButton("Hi!", func() {
hello.SetText("Welcome :)")
}),
))
w.ShowAndRun()
}
错误
go run computer.go
# runtime/cgo
In file included from _cgo_export.c:3:
/usr/local/include/stdlib.h:134:25: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:134:25: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:134:25: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:135:22: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:135:22: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:135:22: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:136:23: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:136:23: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:136:23: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:139:20: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:139:20: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:139:20: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:141:26: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:141:26: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:141:26: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:141:45: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:141:45: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:141:45: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:142:59: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:142:59: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:142:59: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:142:73: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:142:73: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:142:73: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:141:6: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:141:6: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:141:6: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:147:25: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:147:25: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:147:25: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:147:6: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:147:6: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:147:6: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:156:23: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:156:23: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:156:23: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:157:26: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:157:26: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:157:26: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:157:52: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:157:52: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:157:52: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:158:21: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:158:21: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:158:21: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:158:46: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:158:46: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:158:46: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:160:18: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:160:18: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:160:18: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:161:43: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:161:43: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:161:43: note: insert '_Nonnull' if the pointer should never be null
/usr/local/include/stdlib.h:161:57: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
/usr/local/include/stdlib.h:161:57: note: insert '_Nullable' if the pointer may be null
/usr/local/include/stdlib.h:161:57: note: insert '_Nonnull' if the pointer should never be null
fatal error: too many errors emitted, stopping now [-ferror-limit=]
解决
export CGO_CPPFLAGS="-Wno-error -Wno-nullability-completeness -Wno-expansion-to-defined"