garble icon indicating copy to clipboard operation
garble copied to clipboard

JSON parse error

Open rutigl opened this issue 1 year ago • 1 comments

What version of Garble and Go are you using?

$ garble version 0.11.0

$ go version 1.21.5

What environment are you running Garble on?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\mglushki\AppData\Local\go-build
set GOENV=C:\Users\mglushki\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\mglushki\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\mglushki\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=c:\Users\mglushki\go\Dell\src\report\go.mod
set GOWORK=c:\Users\mglushki\go\Dell\go.work
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\mglushki\AppData\Local\Temp\go-build2032865526=/tmp/go-build -gno-record-gcc-switches

What did you do?

My application creates json file. Instead of running go build, I run garble -literals -seed=random -tiny build Here is some code from my application:

package main
import (
	"encoding/json"
	"flag"
	"fmt"	
)
type DeviceData struct {
	UID    string `json:"UID"`
	DMEKey string `json:"DME_KEY"`
}
type Header struct {
	Version      int    `json:"version"`
	ID           int    `json:"ID"`
	Size         int    `json:"size"`
	Timestamp    string `json:"timestamp"`
	DMEAlgorithm string `json:"DMEalgorithm"`
}
type Signature struct {
	Issuer string `json:"issuer"`
	Hash   string `json:"hash"`
	Value  string `json:"value"`
}
type Manifest struct {
	Manifest struct {
		Header    Header       `json:"header"`
		Content   []DeviceData `json:"content"`
		Signature Signature    `json:"signature"`
	} `json:"manifest"`
}

What did you expect to see?

receive report.exe without errors

What did you see instead?

report

:6: cannot use struct{UD9EZ69LsH Header json:"header"; IOsqDhsqaqq []DeviceData json:"content"; C3ZvWW53w Signature json:"signature"}{…} (value of type struct{UD9EZ69LsH Header "json:"header""; IOsqDhsqaqq []DeviceData "json:"content""; C3ZvWW53w Signature "json:"signature""}) as struct{Header Header "json:"header""; Content []DeviceData "json:"content""; Signature Signature "json:"signature""} value in struct literal exit status 2 exit status 1

rutigl avatar Feb 08 '24 08:02 rutigl

This is the same cause as #799

lu4p avatar Feb 08 '24 10:02 lu4p

This issue report doesn't have enough information to reproduce the error, and like @lu4p says, it looks very similar to #799. Closing as a duplicate for now.

mvdan avatar Feb 18 '24 09:02 mvdan