in common/gobuild.py [0:0]
def build(parent, source_dir, target):
# compile...
env = {
"PATH": os.environ["PATH"],
"GOPATH": os.path.abspath(parent),
"GOCACHE": "/tmp",
"GO111MODULE": "off"
}
if os.path.isdir("%s/main" % source_dir):
source_dir += "/main"
p = subprocess.Popen(
["go", "build", "-ldflags=-s -w", "-o", target],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=source_dir,
env=env)
(o, e) = p.communicate()
# stdout/stderr may be either text or bytes, depending on Python
# version, so if bytes, decode to text. Note that in Python 2
# a string will match both types; so also skip decoding in that case
if isinstance(o, bytes) and not isinstance(o, str):
o = o.decode('utf-8')
if isinstance(e, bytes) and not isinstance(e, str):
e = e.decode('utf-8')
# remove the comments mentioning the folder in order to normalize output
o = re.sub(r"# .*\n", "", o, flags=re.MULTILINE)
e = re.sub(r"# .*\n", "", e, flags=re.MULTILINE)
if o:
sys.stdout.write(o)
sys.stdout.flush()
if e:
sys.stderr.write(e)
sys.stderr.flush()