Golang的注释似乎会改变编译器的输入(Sliver)。

huangapple go评论73阅读模式
英文:

Golang Comments seem to alter the compiler input (Sliver)

问题

这种改变编译方式的方法被称为条件编译(Conditional Compilation),它可以通过在代码中插入条件语句来实现。在你提供的代码中,使用了Go语言的条件编译语法。具体来说,这段代码使用了一个条件语句{{if .Config.IsBeacon}},如果.Config.IsBeacon为真,则编译器会将"sync"包包含进来。

这种条件编译的语法并不是Go语言的默认特性,而是通过使用一些工具或库来实现的。在这个项目中,可能使用了一些自定义的构建工具或预处理器来处理这种条件编译。

英文:

I found a in interesting project on Github mainly written in Golang containing comments which seem to change the way the code is compiled:
https://github.com/BishopFox/sliver/blob/master/implant/sliver/sliver.go#L37

// {{if .Config.IsBeacon}}
"sync"
// {{end}}

How is this method of altering the compilation called and how can it be defined - is this default go?

答案1

得分: 1

根据 @burak-serdar 的说法,这很可能是由于使用了 template 包导致的 - 可以在这里看到:https://github.com/BishopFox/sliver/blob/978a66bdb0c93adec7cd81721428ca89340830ec/server/generate/binaries.go#L599

英文:

As indicated by @burak-serdar , this is most likely due to the usage of the template package - as seen here: https://github.com/BishopFox/sliver/blob/978a66bdb0c93adec7cd81721428ca89340830ec/server/generate/binaries.go#L599

huangapple
  • 本文由 发表于 2022年6月7日 01:07:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/72521131.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定