From f4a9cd3cbe000b8419cce89bdb3be92840ca6119 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 14 Jun 2023 19:04:05 +0200 Subject: [PATCH] stdlib: remove embed wrapper Embedding files using `//go:embed` and `embed` packages can not be supported in yaegi, so it is better to not generate the wrapper to embed and have a graceful error in case of usage of `embed.FS` in the interpreter. Also update README about unsuported directives. Fixes #1557. --- README.md | 1 + stdlib/go1_19_embed.go | 18 ------------------ stdlib/go1_20_embed.go | 18 ------------------ stdlib/stdlib.go | 2 +- 4 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 stdlib/go1_19_embed.go delete mode 100644 stdlib/go1_20_embed.go diff --git a/README.md b/README.md index 6c6c31ee6..70cf69dc8 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ Beside the known [bugs] which are supposed to be fixed in the short term, there - Assembly files (`.s`) are not supported. - Calling C code is not supported (no virtual "C" package). +- Directives about the compiler, the linker, or embedding files are not supported. - Interfaces to be used from the pre-compiled code can not be added dynamically, as it is required to pre-compile interface wrappers. - Representation of types by `reflect` and printing values using %T may give different results between compiled mode and interpreted mode. - Interpreting computation intensive code is likely to remain significantly slower than in compiled mode. diff --git a/stdlib/go1_19_embed.go b/stdlib/go1_19_embed.go deleted file mode 100644 index 80356ded6..000000000 --- a/stdlib/go1_19_embed.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by 'yaegi extract embed'. DO NOT EDIT. - -//go:build go1.19 && !go1.20 -// +build go1.19,!go1.20 - -package stdlib - -import ( - "embed" - "reflect" -) - -func init() { - Symbols["embed/embed"] = map[string]reflect.Value{ - // type definitions - "FS": reflect.ValueOf((*embed.FS)(nil)), - } -} diff --git a/stdlib/go1_20_embed.go b/stdlib/go1_20_embed.go deleted file mode 100644 index 3f2df6b95..000000000 --- a/stdlib/go1_20_embed.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by 'yaegi extract embed'. DO NOT EDIT. - -//go:build go1.20 -// +build go1.20 - -package stdlib - -import ( - "embed" - "reflect" -) - -func init() { - Symbols["embed/embed"] = map[string]reflect.Value{ - // type definitions - "FS": reflect.ValueOf((*embed.FS)(nil)), - } -} diff --git a/stdlib/stdlib.go b/stdlib/stdlib.go index ca1d0e4dd..e7fcd46b8 100644 --- a/stdlib/stdlib.go +++ b/stdlib/stdlib.go @@ -35,7 +35,7 @@ func init() { //go:generate ../internal/cmd/extract/extract crypto/subtle crypto/tls crypto/x509 crypto/x509/pkix //go:generate ../internal/cmd/extract/extract database/sql database/sql/driver //go:generate ../internal/cmd/extract/extract debug/buildinfo debug/dwarf debug/elf debug/gosym debug/macho debug/pe debug/plan9obj -//go:generate ../internal/cmd/extract/extract embed encoding encoding/ascii85 encoding/asn1 encoding/base32 +//go:generate ../internal/cmd/extract/extract encoding encoding/ascii85 encoding/asn1 encoding/base32 //go:generate ../internal/cmd/extract/extract encoding/base64 encoding/binary encoding/csv encoding/gob //go:generate ../internal/cmd/extract/extract encoding/hex encoding/json encoding/pem encoding/xml //go:generate ../internal/cmd/extract/extract errors expvar flag fmt