xref: /unit/test/unit/check/go.py (revision 1880:00dc6b211906)
1import os
2import subprocess
3
4
5def check_go(current_dir, temp_dir, test_dir):
6    if not os.path.exists(temp_dir + '/go'):
7        os.mkdir(temp_dir + '/go')
8
9    env = os.environ.copy()
10    env['GOPATH'] = current_dir + '/build/go'
11    env['GO111MODULE'] = 'auto'
12
13    try:
14        process = subprocess.Popen(
15            [
16                'go',
17                'build',
18                '-o',
19                temp_dir + '/go/app',
20                test_dir + '/go/empty/app.go',
21            ],
22            env=env,
23        )
24        process.communicate()
25
26        if process.returncode == 0:
27            return True
28
29    except KeyboardInterrupt:
30        raise
31
32    except:
33        return None
34