Skip to content

Commit

Permalink
Use strings.Join
Browse files Browse the repository at this point in the history
  • Loading branch information
James C. Scott committed Oct 3, 2016
1 parent a5c34ee commit 85e8419
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions commands/docs/gitbook/gitbookSummaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"path/filepath"
"strings"
)

// createSubHeading will create a subheading with the passed in string.
Expand All @@ -23,16 +24,7 @@ func (f fileName) withExt(ext string) string {

// createFileName creates a file name from multiple strings. Between each string, there will be a hyphen between them.
func createFileName(fileNameParts ...string) fileName {
name := ""
for i, fileNamePart := range fileNameParts {
if i == len(fileNameParts)-1 {
// if it's the last part, no need to append the hyphen
name = fmt.Sprintf("%s%s", name, fileNamePart)
} else {
// if there is more left, append the hyphen
name = fmt.Sprintf("%s%s-", name, fileNamePart)
}
}
name := strings.Join(fileNameParts, "-")
return fileName{name: name}
}

Expand Down

0 comments on commit 85e8419

Please sign in to comment.