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

@ -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() {

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,7 +83,7 @@ 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")

View file

@ -328,16 +328,16 @@ 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{}