From 810bdf448eb38779b428633566201fb3de0bb429 Mon Sep 17 00:00:00 2001 From: lu4p <lu4p@pm.me> Date: Wed, 10 Mar 2021 17:51:37 +0100 Subject: [PATCH] don't obfuscate the "embed" import path Updates #263 --- shared.go | 2 +- testdata/scripts/embed.txt | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 testdata/scripts/embed.txt diff --git a/shared.go b/shared.go index be321f9..a516b3f 100644 --- a/shared.go +++ b/shared.go @@ -176,7 +176,7 @@ type listedPackage struct { } func (p *listedPackage) obfuscatedImportPath() string { - if p.Name == "main" || !p.Private { + if p.Name == "main" || p.Name == "embed" || !p.Private { return p.ImportPath } newPath := hashWith(p.GarbleActionID, p.ImportPath) diff --git a/testdata/scripts/embed.txt b/testdata/scripts/embed.txt new file mode 100644 index 0000000..212f243 --- /dev/null +++ b/testdata/scripts/embed.txt @@ -0,0 +1,31 @@ +env GOPRIVATE=* + +garble build + +exec ./main +cmp stdout main.stdout + +-- go.mod -- +module test/main + +go 1.16 + +-- main.go -- +package main + +import ( + _ "embed" + "fmt" +) + +//go:embed test.txt +var x string + +func main() { + fmt.Printf("%q\n", x) +} + +-- test.txt -- +test content +-- main.stdout -- +"test content\n"