in common/gobuild.py [0:0]
def sources(launcher, source_dir, main):
func = main.capitalize()
has_main = None
# copy the exec to exec.go
# also check if it has a main in it
src = "%s/exec" % source_dir
dst = "%s/exec__.go" % source_dir
if os.path.isfile(src):
with codecs.open(src, 'r', 'utf-8') as s:
with codecs.open(dst, 'w', 'utf-8') as d:
body = s.read()
has_main = re.match(r".*package\s+main\W.*func\s+main\s*\(\s*\)", body, flags=re.DOTALL)
d.write(body)
# copy the launcher fixing the main
if not has_main:
dst = "%s/main__.go" % source_dir
if os.path.isdir("%s/main" % source_dir):
dst = "%s/main/main__.go" % source_dir
with codecs.open(dst, 'w', 'utf-8') as d:
with codecs.open(launcher, 'r', 'utf-8') as e:
code = e.read()
code = code.replace("Main", func)
d.write(code)