unixpickle / gobfuscate

Obfuscate Go binaries and packages
BSD 2-Clause "Simplified" License
1.45k stars 157 forks source link

flag provided but not defined #32

Closed notdodo closed 3 years ago

notdodo commented 4 years ago

Hi!

While trying the tool I simply executed:

gobfuscate test ./ and the output was:

2020/02/02 15:22:05 Copying GOPATH...
2020/02/02 15:22:13 Obfuscating package names...
2020/02/02 15:22:13 Obfuscating strings...
2020/02/02 15:22:13 Obfuscating symbols...
Renamed 4 occurrences in 1 file in 1 package.
flag provided but not defined: -ldflags "-s -w -extldflags '-static'"
usage: go build [-o output] [-i] [build flags] [packages]
Run 'go help build' for details.
Failed to compile: exit status 2
exit status 1

I've read that the issue could be due to a regression in Golang 1.13 due to flag.Parse() called before the flags initialization, so I stripped, in main.go

func main() {
    pkgName := "test"
    outPath := "./"

    if !obfuscate(pkgName, outPath) {
        os.Exit(1)
    }
}

But the output is the same of above. Go version is: go1.13.7 linux/amd64

main.go is:

package main

import (
    "fmt"
)

func main() {
    fmt.Println("Hello World!")
}
NeoTheCapt commented 4 years ago

it should be like:

ldflags := `-ldflags="-s -w`
    if winHide {
        ldflags += " -H=windowsgui"
    }
    if !noStaticLink {
        ldflags += ` -extldflags '-static'`
    }
    ldflags += `"`
    tagsFlag := `-tags="` + tags + `"`
danilofaria commented 3 years ago

im having the same issue with a hello world go file