blob: 1a56dd9ceb25196a1368544689d080f2e92fb388 [file] [log] [blame]
#!/usr/bin/env python3
# Copyright 2016 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Runs gofmt on all of Cobalt's go files."""
from __future__ import print_function
import subprocess
from tools import get_files
def main(only_directories=[], all_files=False):
status = 0
files_to_lint = get_files.files_to_lint(('.go',),
print('Linting %d go files' % len(files_to_lint))
if files_to_lint:
p = subprocess.Popen(
['gofmt', '-d'] + files_to_lint, stdout=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
print('Received non-zero return code (%s)' % p.returncode)
status += 1
if len(out) > 0:
print('The following differences were found with gofmt:\n%s' % out)
status += 1
return status
if __name__ == '__main__':