Permalink
Browse files

Update format script for new gofmt

gofmt no longer supports `tabs` and `tabwidth`, but we still require
exactly-4-space tabs to preserve the narrow layout on gobyexample.com,
so re-implement this functionality with sed.
  • Loading branch information...
1 parent a2fe5f2 commit 8e7a6bb08685033cddff20f626896fd269b403b7 @mohae mohae committed with Dec 12, 2014
Showing with 11 additions and 7 deletions.
  1. +1 −1 tools/build
  2. +10 −0 tools/format
  3. +0 −6 tools/gofmt
View
2 tools/build
@@ -2,6 +2,6 @@
set -e
-tools/gofmt
+tools/format
tools/measure
tools/generate
View
10 tools/format
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -eo pipefail
+
+paths=$(ls tools/*.go examples/*/*.go)
+
+for path in $paths; do
+ gofmt -w=true $path
+ sed -i '' -e 's/ / /g' $path
@everyx
everyx added a line comment Dec 19, 2014

Is
sed -i '' -e 's/ / /g' $path should be
sed -i -e 's/ / /g' $path ?

@mmcgrana
Owner
mmcgrana added a line comment Dec 22, 2014

Unfortunately I think the exact sed command is environment dependent. This is the one that works in my environment (Mac with BSD sed). It would be nice to have an more portable command here, maybe Perl or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+done
View
6 tools/gofmt
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-set -e
-set -o pipefail
-
-ls tools/*.go examples/*/*.go | xargs gofmt -tabs=false -tabwidth=4 -w=true

0 comments on commit 8e7a6bb

Please sign in to comment.