Commit c6c733a4 by Torkel Ödegaard

Merge branch 'master' of github.com:grafana/grafana

parents 4a9bc70c a815511a
{
"ImportPath": "github.com/grafana/grafana",
"GoVersion": "go1.3",
"GoVersion": "go1.4.2",
"Packages": [
"./pkg/..."
],
......@@ -14,14 +14,6 @@
"Rev": "93de4f3fad97bf246b838f828e2348f46f21f20a"
},
{
"ImportPath": "github.com/dalu/slug",
"Rev": "6dbd13912e9be466e2c1de349a2c7d1466c97e07"
},
{
"ImportPath": "github.com/dalu/unidecode",
"Rev": "339814d47f3e32a6f7036a0a4c56ed9b373dd755"
},
{
"ImportPath": "github.com/go-sql-driver/mysql",
"Comment": "v1.2-26-g9543750",
"Rev": "9543750295406ef070f7de8ae9c43ccddd44e15e"
......@@ -36,6 +28,10 @@
"Rev": "e2889e5517600b82905f1d2ba8b70deb71823ffe"
},
{
"ImportPath": "github.com/gosimple/slug",
"Rev": "8d258463b4459f161f51d6a357edacd3eef9d663"
},
{
"ImportPath": "github.com/jtolds/gls",
"Rev": "f1ac7f4f24f50328e6bc838ca4437d1612a0243c"
},
......@@ -57,6 +53,10 @@
"Rev": "e28cd440fabdd39b9520344bc26829f61db40ece"
},
{
"ImportPath": "github.com/rainycape/unidecode",
"Rev": "836ef0a715aedf08a12d595ed73ec8ed5b288cac"
},
{
"ImportPath": "github.com/smartystreets/goconvey/convey",
"Comment": "1.5.0-356-gfbc0a1c",
"Rev": "fbc0a1c888f9f96263f9a559d1769905245f1123"
......@@ -87,10 +87,6 @@
"ImportPath": "gopkg.in/redis.v2",
"Comment": "v2.3.2",
"Rev": "e6179049628164864e6e84e973cfb56335748dea"
},
{
"ImportPath": "gopkgs.com/pool.v1",
"Rev": "c850f092aad1780cbffff25f471c5cc32097932a"
}
]
}
......@@ -4,9 +4,10 @@ slug
Package `slug` generate slug from unicode string, URL-friendly slugify with
multiple languages support.
[![GoDoc](https://godoc.org/github.com/dalu/slug?status.png)](https://godoc.org/github.com/dalu/slug)
[![GoDoc](https://godoc.org/github.com/gosimple/slug?status.png)](https://godoc.org/github.com/gosimple/slug)
[![Build Status](https://drone.io/github.com/gosimple/slug/status.png)](https://drone.io/github.com/gosimple/slug/latest)
[Documentation online](http://godoc.org/github.com/dalu/slug)
[Documentation online](http://godoc.org/github.com/gosimple/slug)
## Example
......@@ -37,9 +38,12 @@ multiple languages support.
fmt.Println(textSub) // Will print 'sand-is-hot'
}
### Requests or bugs?
<https://github.com/gosimple/slug/issues>
## Installation
go get -u github.com/dalu/slug
go get -u github.com/gosimple/slug
## License
......
......@@ -12,7 +12,7 @@ Example:
package main
import(
"github.com/dalu/slug"
"github.com/gosimple/slug"
"fmt"
)
......@@ -35,5 +35,9 @@ Example:
textSub := slug.Make("water is hot")
fmt.Println(textSub) // Will print 'sand-is-hot'
}
Requests or bugs?
https://github.com/gosimple/slug/issues
*/
package slug
......@@ -6,9 +6,10 @@
package slug
import (
"github.com/dalu/unidecode"
"regexp"
"strings"
"github.com/rainycape/unidecode"
)
var (
......
......@@ -3,4 +3,4 @@ unidecode
Unicode transliterator in Golang - Replaces non-ASCII characters with their ASCII approximations.
View other available versions, documentation and examples at http://gopkgs.com/unidecode
[![GoDoc](https://godoc.org/github.com/rainycape/unidecode?status.svg)](https://godoc.org/github.com/rainycape/unidecode)
......@@ -5,12 +5,9 @@ import (
"encoding/binary"
"io"
"strings"
"sync"
)
var (
decoded = false
mutex sync.Mutex
transliterations [65536][]rune
transCount = rune(len(transliterations))
getUint16 = binary.LittleEndian.Uint16
......
......@@ -4,15 +4,15 @@
package unidecode
import (
"sync"
"unicode"
"gopkgs.com/pool.v1"
)
const pooledCapacity = 64
var (
slicePool = pool.New(0)
slicePool sync.Pool
decodingOnce sync.Once
)
// Unidecode implements a unicode transliterator, which
......@@ -23,14 +23,7 @@ var (
// with their closest ASCII counterparts.
// e.g. Unicode("áéíóú") => "aeiou"
func Unidecode(s string) string {
if !decoded {
mutex.Lock()
if !decoded {
decodeTransliterations()
decoded = true
}
mutex.Unlock()
}
decodingOnce.Do(decodeTransliterations)
l := len(s)
var r []rune
if l > pooledCapacity {
......
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
pool
====
sync.Pool compatibility layer for for Go - falls back to a channel based pool in Go &lt; 1.3
Please, use the following import path to ensure a stable API:
```go
import "gopkgs.com/pool.v1"
```
View other available versions, documentation and examples at http://gopkgs.com/pool
// Package pool provides a sync.Pool compatibility layer, which
// falls back to a channel based pool on Go < 1.3.
package pool
package pool_test
import (
"fmt"
"gopkgs.com/pool.v1"
)
func ExamplePool() {
p := pool.New(0)
p.Put("Hello")
fmt.Println(p.Get())
// OutPut: Hello
}
func ExamplePoolNew() {
p := pool.New(0)
p.New = func() interface{} {
return "World!"
}
fmt.Println(p.Get())
// OutPut: World!
}
package pool
import (
"fmt"
"reflect"
)
// gopkgs.go: v1
// NOTE: This file is autogenerated by gopkgs.com.
const (
goPkgsSrcPath = "github.com/rainycape/pool"
goPkgsName = "pool"
goPkgsErrFmt = "invalid import path %s - please use gopkgs.com/%s.v1 or see http://gopkgs.com/%s"
)
type goPkgsCheck struct{}
func init() {
typ := reflect.TypeOf(goPkgsCheck{})
if typ.PkgPath() == goPkgsSrcPath {
panic(fmt.Errorf(goPkgsErrFmt, typ.PkgPath(), goPkgsName, goPkgsName))
}
}
// +build go1.3,!appengine
package pool
import (
"sync"
)
// Pool is a thin compatibility type to allow Go
// libraries to use the new sync.Pool in Go 1.3,
// while remaining compatible with lower Go versions.
// For more information, see the sync.Pool type.
type Pool sync.Pool
// New returns a new Pool. The size argument is
// ignored on Go >= 1.3. In Go < 1.3, if size is
// zero, it's set to runtime.GOMAXPROCS(0) * 2.
func New(size int) *Pool {
return &Pool{}
}
// Get returns an arbitrary previously Put value, removing
// it from the pool, or nil if there are no such values. Note
// that callers should not assume anything about the Get return
// value, since the runtime might decide to collect the elements
// from the pool at any time.
//
// If there are no elements to return and the New() field is non-nil,
// Get returns the result of calling it.
func (p *Pool) Get() interface{} {
return (*sync.Pool)(p).Get()
}
// Put adds x to the pool.
func (p *Pool) Put(x interface{}) {
(*sync.Pool)(p).Put(x)
}
// +build !go1.3 appengine
package pool
import (
"runtime"
)
// Pool is a thin compatibility type to allow Go
// libraries to use the new sync.Pool in Go 1.3,
// while remaining compatible with lower Go versions.
// For more information, see the sync.Pool type.
type Pool struct {
ch chan interface{}
// New specifies a function to generate
// a new value, when Get would otherwise
// return nil.
New func() interface{}
}
// New returns a new Pool. The size argument is
// ignored on Go >= 1.3. In Go < 1.3, if size is
// zero, it's set to runtime.GOMAXPROCS(0) * 2.
func New(size int) *Pool {
if size == 0 {
size = runtime.GOMAXPROCS(0) * 2
}
return &Pool{ch: make(chan interface{}, size)}
}
// Get returns an arbitrary previously Put value, removing
// it from the pool, or nil if there are no such values. Note
// that callers should not assume anything about the Get return
// value, since the runtime might decide to collect the elements
// from the pool at any time.
//
// If there are no elements to return and the New() field is non-nil,
// Get returns the result of calling it.
func (p *Pool) Get() interface{} {
select {
case x := <-p.ch:
return x
default:
}
if p.New != nil {
return p.New()
}
return nil
}
// Put adds x to the pool.
func (p *Pool) Put(x interface{}) {
select {
case p.ch <- x:
default:
}
}
......@@ -5,7 +5,7 @@ import (
"strings"
"time"
"github.com/dalu/slug"
"github.com/gosimple/slug"
)
// Typed errors
......@@ -49,7 +49,7 @@ func NewDashboard(title string) *Dashboard {
// GetTags turns the tags in data json into go string array
func (dash *Dashboard) GetTags() []string {
jsonTags := dash.Data["tags"]
if jsonTags == nil {
if jsonTags == nil || jsonTags == "" {
return []string{}
}
......
......@@ -15,4 +15,17 @@ func TestDashboardModel(t *testing.T) {
So(dashboard.Slug, ShouldEqual, "grafana-play-home")
})
Convey("Given a dashboard json", t, func() {
json := map[string]interface{}{
"title": "test dash",
}
Convey("With tags as string value", func() {
json["tags"] = ""
dash := NewDashboardFromJson(json)
So(len(dash.GetTags()), ShouldEqual, 0)
})
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment