Apply project wide go fmt

This commit is contained in:
Bjørn Erik Pedersen 2015-10-12 20:47:06 +02:00
parent c274e21356
commit 72f14a8202
8 changed files with 28 additions and 29 deletions

View file

@ -33,10 +33,10 @@ var unsafe bool
var convertCmd = &cobra.Command{ var convertCmd = &cobra.Command{
Use: "convert", Use: "convert",
Short: "Convert your content to different formats", Short: "Convert your content to different formats",
Long: `Convert your content (e.g. front matter) to different formats. Long: `Convert your content (e.g. front matter) to different formats.
See convert's subcommands toJSON, toTOML and toYAML for more information.`, See convert's subcommands toJSON, toTOML and toYAML for more information.`,
Run: nil, Run: nil,
} }
var toJSONCmd = &cobra.Command{ var toJSONCmd = &cobra.Command{

View file

@ -30,10 +30,10 @@ func init() {
var listCmd = &cobra.Command{ var listCmd = &cobra.Command{
Use: "list", Use: "list",
Short: "Listing out various types of content", Short: "Listing out various types of content",
Long: `Listing out various types of content. Long: `Listing out various types of content.
List requires a subcommand, e.g. ` + "`hugo list drafts`.", List requires a subcommand, e.g. ` + "`hugo list drafts`.",
Run: nil, Run: nil,
} }
var listDraftsCmd = &cobra.Command{ var listDraftsCmd = &cobra.Command{
@ -64,7 +64,7 @@ var listDraftsCmd = &cobra.Command{
var listFutureCmd = &cobra.Command{ var listFutureCmd = &cobra.Command{
Use: "future", Use: "future",
Short: "List all posts dated in the future", Short: "List all posts dated in the future",
Long: `List all of the posts in your content directory which will be Long: `List all of the posts in your content directory which will be
posted in the future.`, posted in the future.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {

View file

@ -26,10 +26,10 @@ import (
var undraftCmd = &cobra.Command{ var undraftCmd = &cobra.Command{
Use: "undraft path/to/content", Use: "undraft path/to/content",
Short: "Undraft changes the content's draft status from 'True' to 'False'", Short: "Undraft changes the content's draft status from 'True' to 'False'",
Long: `Undraft changes the content's draft status from 'True' to 'False' Long: `Undraft changes the content's draft status from 'True' to 'False'
and updates the date to the current date and time. and updates the date to the current date and time.
If the content's draft status is 'False', nothing is done.`, If the content's draft status is 'False', nothing is done.`,
Run: Undraft, Run: Undraft,
} }
// Publish publishes the specified content by setting its draft status // Publish publishes the specified content by setting its draft status

View file

@ -4,9 +4,9 @@ import (
"bytes" "bytes"
"html" "html"
"github.com/miekg/mmark"
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/miekg/mmark"
) )
// Wraps a blackfriday.Renderer, typically a blackfriday.Html // Wraps a blackfriday.Renderer, typically a blackfriday.Html

View file

@ -1,14 +1,15 @@
package helpers package helpers
import ( import (
"testing"
"github.com/spf13/viper"
"bytes" "bytes"
"github.com/spf13/viper"
"testing"
) )
// Renders a codeblock using Blackfriday // Renders a codeblock using Blackfriday
func render(input string) string { func render(input string) string {
ctx := &RenderingContext{}; ctx := &RenderingContext{}
render := GetHTMLRenderer(0, ctx); render := GetHTMLRenderer(0, ctx)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
render.BlockCode(buf, []byte(input), "html") render.BlockCode(buf, []byte(input), "html")
@ -17,15 +18,14 @@ func render(input string) string {
// Renders a codeblock using Mmark // Renders a codeblock using Mmark
func renderWithMmark(input string) string { func renderWithMmark(input string) string {
ctx := &RenderingContext{}; ctx := &RenderingContext{}
render := GetMmarkHtmlRenderer(0, ctx); render := GetMmarkHtmlRenderer(0, ctx)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
render.BlockCode(buf, []byte(input), "html", []byte(""), false, false) render.BlockCode(buf, []byte(input), "html", []byte(""), false, false)
return buf.String() return buf.String()
} }
func TestCodeFence(t *testing.T) { func TestCodeFence(t *testing.T) {
if !HasPygments() { if !HasPygments() {
@ -38,7 +38,7 @@ func TestCodeFence(t *testing.T) {
input, expected string input, expected string
} }
data := []test{ data := []test{
{true, "<html></html>", "<div class=\"highlight\"><pre><span class=\"nt\">&lt;html&gt;&lt;/html&gt;</span>\n</pre></div>\n"}, {true, "<html></html>", "<div class=\"highlight\"><pre><span class=\"nt\">&lt;html&gt;&lt;/html&gt;</span>\n</pre></div>\n"},
{false, "<html></html>", "<pre><code class=\"language-html\">&lt;html&gt;&lt;/html&gt;</code></pre>\n"}, {false, "<html></html>", "<pre><code class=\"language-html\">&lt;html&gt;&lt;/html&gt;</code></pre>\n"},
} }

View file

@ -98,7 +98,7 @@ func Highlight(code, lang, optsStr string) string {
if lang == "" { if lang == "" {
langOpt = "-g" // Try guessing the language langOpt = "-g" // Try guessing the language
} else { } else {
langOpt = "-l"+lang langOpt = "-l" + lang
} }
cmd := exec.Command(pygmentsBin, langOpt, "-fhtml", "-O", options) cmd := exec.Command(pygmentsBin, langOpt, "-fhtml", "-O", options)

View file

@ -83,12 +83,12 @@ func Dictionary(values ...interface{}) (map[string]interface{}, error) {
return nil, errors.New("invalid dict call") return nil, errors.New("invalid dict call")
} }
dict := make(map[string]interface{}, len(values)/2) dict := make(map[string]interface{}, len(values)/2)
for i := 0; i < len(values); i+=2 { for i := 0; i < len(values); i += 2 {
key, ok := values[i].(string) key, ok := values[i].(string)
if !ok { if !ok {
return nil, errors.New("dict keys must be strings") return nil, errors.New("dict keys must be strings")
} }
dict[key] = values[i+1] dict[key] = values[i+1]
} }
return dict, nil return dict, nil
} }

View file

@ -326,18 +326,18 @@ func TestAfter(t *testing.T) {
func TestDictionary(t *testing.T) { func TestDictionary(t *testing.T) {
for i, this := range []struct { for i, this := range []struct {
v1 []interface{} v1 []interface{}
expecterr bool expecterr bool
expectedValue map[string] interface{} expectedValue map[string]interface{}
}{ }{
{[]interface{}{"a", "b"}, false, map[string]interface{}{"a":"b"}}, {[]interface{}{"a", "b"}, false, map[string]interface{}{"a": "b"}},
{[]interface{}{5, "b"}, true,nil}, {[]interface{}{5, "b"}, true, nil},
{[]interface{}{"a", 12,"b",[]int{4}}, false,map[string]interface{}{"a":12,"b":[]int{4}}}, {[]interface{}{"a", 12, "b", []int{4}}, false, map[string]interface{}{"a": 12, "b": []int{4}}},
{[]interface{}{"a", "b", "c"}, true,nil}, {[]interface{}{"a", "b", "c"}, true, nil},
} { } {
r,e := Dictionary(this.v1...) r, e := Dictionary(this.v1...)
if (this.expecterr && e==nil) || (!this.expecterr && e!=nil) { if (this.expecterr && e == nil) || (!this.expecterr && e != nil) {
t.Errorf("[%d] got an unexpected error", i, e, this.expecterr) t.Errorf("[%d] got an unexpected error", i, e, this.expecterr)
} else if !this.expecterr { } else if !this.expecterr {
if !reflect.DeepEqual(r, this.expectedValue) { if !reflect.DeepEqual(r, this.expectedValue) {
@ -347,7 +347,6 @@ func TestDictionary(t *testing.T) {
} }
} }
func TestIn(t *testing.T) { func TestIn(t *testing.T) {
for i, this := range []struct { for i, this := range []struct {
v1 interface{} v1 interface{}