Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shgopher/short
URL shortening service. 高性能短链接服务。
https://github.com/shgopher/short
docker gin go go-micro k8s mysql redis rocketmq shortening-urls url vue
Last synced: 2 months ago
JSON representation
URL shortening service. 高性能短链接服务。
- Host: GitHub
- URL: https://github.com/shgopher/short
- Owner: shgopher
- License: mit
- Created: 2020-03-20T14:35:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-25T20:38:22.000Z (over 1 year ago)
- Last Synced: 2024-11-02T13:50:19.315Z (3 months ago)
- Topics: docker, gin, go, go-micro, k8s, mysql, redis, rocketmq, shortening-urls, url, vue
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 18
- Watchers: 5
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: history.md
- License: LICENSE
Awesome Lists containing this project
README
# short
URL shortening service.
## Usage
[example](./example/example.go)
```go
package mainimport (
"fmt"
"github.com/golang/glog"
"github.com/googege/short"
"os"
)var (
path = "https://t.cn/"
longURL = "https://github.com/googege/GOFamily/blob/master/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/%E7%AE%97%E6%B3%95/%E7%AE%97%E6%B3%95%E9%A2%98/leetcode/1.md"
)func main() {
db := short.NewMapDB()
// add db engine to short.
s := short.NewShort(db)
//
shortURL, err := s.ShortAdd(longURL)
if err != nil {
glog.Error(err)
} else {
fmt.Println(shortURL)
}
//
longURL, err = s.ShortFind(path + shortURL)
// if http
//http.Redirect(nil,nil,longURL,302
//)
if err != nil {
glog.Error(err)
} else {
fmt.Println("longURL:", longURL)
}
//
shortURL, err = s.ShortFind("a")
if err != nil {
glog.Error(err)
} else {
fmt.Println("short: ", shortURL)
}
//
file, err := os.Getwd()
if err != nil {
glog.Error(err)
}
if err = s.SetQR(path, 256, file+"/text.png"); err != nil {
glog.Error(err)
}
}```
## HERE
微信公众号:科科人神关注我了解更多软件知识。