Skip to content

Commit

Permalink
separate gofumpt code into an importable package
Browse files Browse the repository at this point in the history
To allow offering a drop-in replacement for goimports.
  • Loading branch information
mvdan committed Apr 9, 2019
1 parent bdb9bda commit 9ef2c07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gofmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"runtime"
"runtime/pprof"
"strings"

"mvdan.cc/gofumpt/internal"
)

var (
Expand Down Expand Up @@ -116,7 +118,7 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error

// This is the only gofumpt change on gofmt's codebase, besides changing
// the name in the usage text.
gofumpt(fileSet, file)
internal.Gofumpt(fileSet, file)

res, err := format(fileSet, file, sourceAdj, indentAdj, src, printer.Config{Mode: printerMode, Tabwidth: tabWidth})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions gofumpt.go → internal/gofumpt.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2019, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information

package main
package internal

import (
"fmt"
Expand All @@ -14,7 +14,7 @@ import (
"unicode/utf8"
)

func gofumpt(fset *token.FileSet, file *ast.File) {
func Gofumpt(fset *token.FileSet, file *ast.File) {
f := &fumpter{
fset: fset,
file: fset.File(file.Pos()),
Expand Down

0 comments on commit 9ef2c07

Please sign in to comment.