revel

Parsing a json datetime in revel

本秂侑毒 提交于 2019-12-24 00:08:56
问题 I'm attempting to parse a Datetime in revel from a json request. The request looks something like this: { "startedAt": "2017-06-01 10:39", ... } The struct it's being decoded into looks like this: type MyStruct struct { StartedAt time.Time `json:"startedAt" bson:"startedAt"` ... } The decode line looks like this: json.NewDecoder(c.Request.Body).Decode(&MyStruct) Revel returns this error: interface conversion: error is *time.ParseError, not *errors.Error According to revel's documentation here

go 语言

我是研究僧i 提交于 2019-12-21 04:14:37
go 语言 revel 缓存 站内搜索 和 字典 数据库 的关系 https://golang.org/doc/ 这段时间一直在看Go语言,6月3日Apple发布了swift发现里面竟然也有许多Go语言的影子,截至现在每天都在感觉到Go语言的强大。确实值得一学 今天在这里给园友们推荐一些Go语言的学习资料 网站 Go 中文社区 Go官方网站 http://golang.org/ 需FQ Go中文官网 http://golang-china.org/ 中文论坛(测试中…) http://bbs.golang-china.org/ 中文用户讨论组(邮件) https://groups.google.com/group/golang-china/ 中文翻译(SVN) http://code.google.com/p/golang-china/ GitHub与Google Code同步(GIT) http://github.com/border/golang-china QQ群: 102319854(申请加入请到中文论坛留言) 几个非官方的网站 也比较好 Go语言中文论坛 http://golang.usr.cc/ GoLang中文社区 http://studygolang.com/ GoLang中国 Go语言开发常用支持包 http://www.golangtc.com/packages

how to debug revel framework(golang) application in visual studio code(vscode)

梦想与她 提交于 2019-12-12 17:39:11
问题 { "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "attach", "mode": "debug", "remotePath": "", "port": 2345, "host": "127.0.0.1", "program": "revel.exe", "env": {}, "args": [], "showLog": true }, ] } how to debug revel framework(golang) application in visual studio code(vscode) how to write the configuration file(launch.json) 回答1: Here are the steps to debug a revel framework (golang) app in vscode. Import revel project folder into vscode Edit ~/.vscode

Go JSON decoding is very slow. What would be a better way to do it?

怎甘沉沦 提交于 2019-12-12 10:53:04
问题 I am using Go, Revel WAF and Redis. I have to store large json data in Redis (maybe 20MB). json.Unmarshal() takes about roughly 5 seconds. What would be a better way to do it? I tried JsonLib, encode/json, ffjson, megajson, but none of them were fast enough. I thought about using groupcache, but Json is updated in real time. This is the sample code: package main import ( "github.com/garyburd/redigo/redis" json "github.com/pquerna/ffjson/ffjson" ) func main() { c, err := redis.Dial("tcp", "

Iterate Go map get index

做~自己de王妃 提交于 2019-12-10 15:45:13
问题 In order to use revel 's even keyword in templates I would like to get the index of a map entry when iterating with range . Is there any way to do so? My map has the structure: map[string][]string 回答1: You can't do this only with template actions, but you may register a function which provides the necessary help. You may register a function which returns a function (closure), which alternates its return value whenever called (exactly how "odd" and "even" indices alternate): func isEven() func

Golang template.ParseFiles “not a directory” error

喜欢而已 提交于 2019-12-08 12:18:09
问题 I'm trying to render just one template: root_path, err := osext.Executable() if err != nil { return err } template_path := root_path + "/app/views/mailtemplates/" + "feedback.html" fmt.Println(exist(template_path)) tmpl, err := template.ParseFiles(template_path) if err != nil { return err } but I have the error not a directory . My exist function: func exist(file_path string) bool { if _, err := os.Stat(file_path); os.IsNotExist(err) { return false } return true } it returns true . What's the

Golang Revel freezes when download gopkg.in/fsnotify.v1

谁说我不能喝 提交于 2019-12-08 07:06:37
问题 I'm using CentOS7; tried downloading the golang 1.5.1 binary and also yum install golang , and run into the same problem installed revel. Go works fine; when I do go version it displays the proper version. When I type go get -v github.com/revel/revel , a few packages download just fine.... until it gets to fsnotify. Then I get this output: Fetching https://gopkg.in/fsnotify.v1?go-get=1 Parsing meta tags from https://gopkg.in/fsnotify.v1?go-get=1 (status code 200) get "gopkg.in/fsnotify.v1":

Can't install Revel (Unrecognized import path)

牧云@^-^@ 提交于 2019-12-07 10:31:13
问题 I'm a beginner in Go and I would like to use the Revel web framework. I installed: Git; Mercurial and even: Bazaar and CVS. I checked my environment variables. I set environment variable GOPATH to D:\Go and added D:\Go\bin to PATH.But I still get these errors when I go get The Revel Framework ( go get github.com/revel/revel ) ** package golang.org/x/net/websocket: unrecognized import path "golang.org/x/net/websocket" package gopkg.in/fsnotify.v1: unrecognized import path "gopkg.in/fsnotify.v1

Golang requirements.txt equivalent

懵懂的女人 提交于 2019-12-06 18:42:13
问题 Coming from a python/django world, it'd be great to have something like a requirements.txt equivalent for go/revel. How can I do this? I know I can just write a requirements.txt file and then do something like cat reqiurements.txt | xargs go get But what if my requirements ALSO have requirements? The above command would attempt to "go get" them, and then they'd fail to build, since I don't have those requirements installed. Is there something I'm missing? 回答1: The command go get does exactly

Revel doesn't forward to port 443 when SSL enabled

两盒软妹~` 提交于 2019-12-06 08:13:11
问题 I'm using Revel for a small app and added SSL. When I update the config to point to http.port = 443, requests to port 80 are rejected instead of being forwarded. Is there a way to fix this on the Revel Framework? Thank you. # The port on which to listen. http.port = 443 # Whether to use SSL or not. http.ssl = true # Path to an X509 certificate file, if using SSL. http.sslcert = /root/go/src/saml/AlphaCerts/cert.crt # Path to an X509 certificate key, if using SSL. http.sslkey = /root/go/src