In Go 1.16, the module-aware mode is enabled by default; to fall back to previous behavior, the GO111MODULE environment variable should be set to 'auto'. Details: https://golang.org/doc/go1.16
34 lines
693 B
Python
34 lines
693 B
Python
import os
|
|
import subprocess
|
|
|
|
|
|
def check_go(current_dir, temp_dir, test_dir):
|
|
if not os.path.exists(temp_dir + '/go'):
|
|
os.mkdir(temp_dir + '/go')
|
|
|
|
env = os.environ.copy()
|
|
env['GOPATH'] = current_dir + '/build/go'
|
|
env['GO111MODULE'] = 'auto'
|
|
|
|
try:
|
|
process = subprocess.Popen(
|
|
[
|
|
'go',
|
|
'build',
|
|
'-o',
|
|
temp_dir + '/go/app',
|
|
test_dir + '/go/empty/app.go',
|
|
],
|
|
env=env,
|
|
)
|
|
process.communicate()
|
|
|
|
if process.returncode == 0:
|
|
return True
|
|
|
|
except KeyboardInterrupt:
|
|
raise
|
|
|
|
except:
|
|
return None
|