@ -54,7 +54,7 @@ func init() {
flagSet . Usage = usage
flagSet . BoolVar ( & flagGarbleLiterals , "literals" , false , "Obfuscate literals such as strings" )
flagSet . BoolVar ( & flagGarbleTiny , "tiny" , false , "Optimize for binary size, losing the ability to reverse the process" )
flagSet . StringVar ( & flagDebugDir , "debugdir" , "" , "Write the garbl ed source to a directory, e.g. -debugdir=out")
flagSet . StringVar ( & flagDebugDir , "debugdir" , "" , "Write the obfuscat ed source to a directory, e.g. -debugdir=out")
flagSet . StringVar ( & flagSeed , "seed" , "" , "Provide a base64-encoded seed, e.g. -seed=o9WDTZ4CN4w\nFor a random seed, provide -seed=random" )
}
@ -396,7 +396,7 @@ func toolexecCmd(command string, args []string) (*exec.Cmd, error) {
goArgs = append ( goArgs , "-a" )
}
if command == "test" {
// vet is generally not useful on garbl ed code; keep it
// vet is generally not useful on obfuscat ed code; keep it
// disabled by default.
goArgs = append ( goArgs , "-vet=off" )
}
@ -629,7 +629,7 @@ func transformCompile(args []string) ([]string, error) {
lit . Value = "`unknown`"
case strings . HasPrefix ( origName , "_cgo_" ) :
// Cgo generated code requires a prefix. Also, don't
// garbl e it, since it's just generated code and it gets
// obfuscat e it, since it's just generated code and it gets
// messy.
name = "_cgo_" + name
default :
@ -756,7 +756,7 @@ func (tf *transformer) handleDirectives(comments []*ast.CommentGroup) {
}
obfPkg := obfuscatedTypesPackage ( pkgPath )
if obfPkg != nil && obfPkg . Scope ( ) . Lookup ( name ) != nil {
continue // the name exists and was not garbl ed
continue // the name exists and was not obfuscat ed
}
// The name exists and was obfuscated; replace the
@ -1093,7 +1093,7 @@ func (tf *transformer) transformGo(file *ast.File) *ast.File {
return true
}
// if the struct of this field was not garbled, do not garbl e
// if the struct of this field was not obfuscated, do not obfuscat e
// any of that struct's fields
if parentScope != tf . pkg . Scope ( ) && x . IsField ( ) && ! x . Embedded ( ) {
parent , ok := cursor . Parent ( ) . ( * ast . SelectorExpr )
@ -1126,8 +1126,8 @@ func (tf *transformer) transformGo(file *ast.File) *ast.File {
return true
}
// if the type was not garbl ed in the package were it was defined,
// do not garbl e it here
// if the type was not obfuscat ed in the package were it was defined,
// do not obfuscat e it here
if parentScope != tf . pkg . Scope ( ) {
named := namedType ( x . Type ( ) )
if named == nil {
@ -1157,11 +1157,11 @@ func (tf *transformer) transformGo(file *ast.File) *ast.File {
}
obfPkg := obfuscatedTypesPackage ( path )
// Check if the imported name wasn't garbl ed.
// If the object returned from the garbl ed package's scope has a
// Check if the imported name wasn't obfuscat ed.
// If the object returned from the obfuscat ed package's scope has a
// different type as the object we're searching for, they are
// most likely two separate objects with the same name, so ok to
// garble
// obfuscate.
if obfPkg == nil {
// TODO(mvdan): This is probably a bug.
// Add a test case where an indirect package has a name
@ -1235,8 +1235,9 @@ func transformLink(args []string) ([]string, error) {
return nil , err
}
// Make sure -X works with garbled identifiers. To cover both garbled
// and non-garbled names, duplicate each flag with a garbled version.
// Make sure -X works with obfuscated identifiers.
// To cover both obfuscated and non-obfuscated names,
// duplicate each flag with a obfuscated version.
flagValueIter ( flags , "-X" , func ( val string ) {
// val is in the form of "pkg.name=str"
i := strings . IndexByte ( val , '=' )