def go_license_detector(notice_out, deps_out, modules):
    modules_json = '\n'.join(map(json.dumps, modules))
    beats_deps_template_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'dependencies.csv.tmpl')
    beats_notice_template_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'NOTICE.txt.tmpl')
    beats_overrides_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'overrides.json')
    beats_rules_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'rules.json')
    beats_notice_template = open(beats_notice_template_path).read()
    beats_overrides = open(beats_overrides_path).read()
    with tempfile.TemporaryDirectory() as tmpdir:
        overrides_file = open(os.path.join(tmpdir, 'overrides.json'), 'w')
        overrides_file.write(beats_overrides)
        overrides_file.write('\n')
        for entry in notice_overrides:
            overrides_file.write('\n')
            json.dump(entry, overrides_file)
        overrides_file.close()
        notice_template_file = open(os.path.join(tmpdir, 'NOTICE.txt.tmpl'), 'w')
        notice_template_file.write(beats_notice_template.replace('Elastic Beats', 'Elastic APM Server'))
        notice_template_file.close()
        args = ['go', 'run', 'go.elastic.co/go-licence-detector', '-includeIndirect', '-overrides', overrides_file.name, '-rules', beats_rules_path, '-noticeTemplate', notice_template_file.name, '-depsTemplate', beats_deps_template_path, '-noticeOut', notice_out, '-depsOut', deps_out]
        subprocess.run(args, check=True, input=modules_json.encode('utf-8'))
def go_license_detector(notice_out, deps_out, modules):
    modules_json = '\n'.join(map(json.dumps, modules))
    beats_deps_template_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'dependencies.csv.tmpl')
    beats_notice_template_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'NOTICE.txt.tmpl')
    beats_overrides_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'overrides.json')
    beats_rules_path = os.path.join(BEATS_DIR, 'dev-tools', 'notice', 'rules.json')
    beats_notice_template = open(beats_notice_template_path).read()
    beats_overrides = open(beats_overrides_path).read()
    with tempfile.TemporaryDirectory() as tmpdir:
        overrides_file = open(os.path.join(tmpdir, 'overrides.json'), 'w')
        overrides_file.write(beats_overrides)
        overrides_file.write('\n')
        for entry in notice_overrides:
            overrides_file.write('\n')
            json.dump(entry, overrides_file)
        overrides_file.close()
        notice_template_file = open(os.path.join(tmpdir, 'NOTICE.txt.tmpl'), 'w')
        notice_template_file.write(beats_notice_template.replace('Elastic Beats', 'Elastic APM Server'))
        notice_template_file.close()
        args = ['go', 'run', 'go.elastic.co/go-licence-detector', '-includeIndirect', '-overrides', overrides_file.name, '-rules', beats_rules_path, '-noticeTemplate', notice_template_file.name, '-depsTemplate', beats_deps_template_path, '-noticeOut', notice_out, '-depsOut', deps_out]
        subprocess.run(args, check=True, input=modules_json.encode('utf-8'))