burrowers / garble

Obfuscate Go builds
BSD 3-Clause "New" or "Revised" License
3.73k stars 239 forks source link

Go-jet compatibility #856

Closed Catalin2092 closed 1 month ago

Catalin2092 commented 1 month ago

What version of Garble and Go are you using?

$ garble version
v0.12.1
$ go version
go version go1.22.2 windows/amd64

What environment are you running Garble on?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\myUser\AppData\Local\go-build
set GOENV=C:\Users\myUser\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\myUser\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\myUser\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.22.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
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\myUser\AppData\Local\Temp\go-build1460770903=/tmp/go-build -gno-record-gcc-switches

What did you do?

Install go-jet and jet/cmd -> run jet -dsn=postgresql://db.User:db.Pass@db.Host:db:Port/db.Name?sslmode=disable -schema=db.Schema -path=./.jet

What did you expect to see?

For the process to work like on normal build.

What did you see instead?

The var _ = reflect.TypeOf(model.Models{}) is not skipping obfuscating the Models struct and when using

var result []model.Models{}
stmt := jet.SELECT(T.Models.AllColumns).FROM(T.Models).ORDER_BY(T.Models.Model.ASC())

err := stmt.Query(C.DB, &result)

The result will be [] and err nil.

I did another test and with var result model.Models{} and the result is like

"FgsKgvJXvY8R": 0,
    "A_y8V5uQfliV": "",
    "Ya3R6FbzgZ": null,
    "TETs4xP2": null

The Models located in .jet/db.Name/public/model:

type Models struct {
    ID        int64 `sql:"primary_key"`
    Model     string
    CreatedAt *time.Time
    UpdatedAt *time.Time
}
lu4p commented 1 month ago

You need to add the hint in the package where Models is declared not when it's imported.