Comments (22)
HI,你好。使用最新的版本,添加这两个环境变量到系统中 ,即可切换到mysql
liteblog_db_type = mysql
liteblog_db_url = user:pwd@tcp(address:port)/dbname?parseTime=true
from liteblog.
我将本项目中引用都改成了项目的引用,不在使用github的引用路径(例如"liteblog/models"),结果登陆、访问的时候都提示非法访问,这个是什么情况
from liteblog.
你看下,要确保 views目录和static目录 一定要在运行目录下。
from liteblog.
2018/10/17 10:45:56.649 [main.go:768] [ORM] sqlE:/GOPATH/src/qomo/models/core.go:50179msSELECT count(*) FROM
users WHERE
users.
deleted_atIS NULL[] 0 2018/10/17 10:45:56.688 [I] [router.go:269] E:\GOPATH\src\qomo\controllers no changed 2018/10/17 10:45:56.689 [I] [router.go:269] E:\GOPATH\src\qomo\controllers no changed 2018/10/17 10:45:56.690 [I] [router.go:269] E:\GOPATH\src\qomo\controllers no changed 2018/10/17 10:45:56.690 [I] [router.go:269] E:\GOPATH\src\qomo\controllers no changed 2018/10/17 10:45:56.692 [I] [router.go:269] E:\GOPATH\src\qomo\controllers no changed 2018/10/17 10:45:57.149 [I] [asm_amd64.s:2361] http server Running on http://:8080 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] the request url is / 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] Handler crashed with error runtime error: invalid memory address or nil pointer dereference 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/runtime/asm_amd64.s:573 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/runtime/panic.go:502 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/runtime/panic.go:63 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/runtime/signal_windows.go:167 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] E:/GOPATH/src/github.com/jinzhu/gorm/main.go:743 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] E:/GOPATH/src/github.com/jinzhu/gorm/main.go:463 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] E:/GOPATH/src/qomo/models/note.go:37 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] E:/GOPATH/src/qomo/controllers/index.go:20 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/runtime/asm_amd64.s:573 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/reflect/value.go:447 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] C:/Go/src/reflect/value.go:308 2018/10/17 10:48:50.822 [C] [asm_amd64.s:573] E:/GOPATH/src/github.com/astaxie/beego/router.go:847 2018/10/17 10:48:50.823 [C] [asm_amd64.s:573] C:/Go/src/net/http/server.go:2694 2018/10/17 10:48:50.823 [C] [asm_amd64.s:573] C:/Go/src/net/http/server.go:1830 2018/10/17 10:48:50.823 [C] [asm_amd64.s:573] C:/Go/src/runtime/asm_amd64.s:2361
修改数据库为mysql,项目内部引用改为自己的,不引用github的路径,结果抱着个错误,网页端也提示
qomo:runtime error: invalid memory address or nil pointer dereference
请问这是什么问题啊
from liteblog.
问题出在 index.go中的Get()方法中的
if ns, _ := c.Dao.QueryNotesByPage(page, limit, title); ns != nil { c.Data["notes"] = ns }
的查询
from liteblog.
可能mysql数据库没有初始化成功。你试下sqlite3是否能正常
from liteblog.
from liteblog.
这两处也改了
from liteblog.
改下上面错误的那段代码,然后看下日志 。
原来的代码:
if ns, _ := c.Dao.QueryNotesByPage(page, limit, title); ns != nil { c.Data["notes"] = ns }{
c.Data["notes"] = ns
}
改成下面的代码
if c.Dao==nil{
c.Abort500(errors.New("数据库初始化失败!"))
}
ns, err := c.Dao.QueryNotesByPage(page, limit, title)
if err != nil {
c.Abort500(err)
}
if ns != nil {
c.Data["notes"] = ns
}
from liteblog.
errors 是引用哪个包的,直接替换,这个errors报错
from liteblog.
import 里面加上"errors",golang自带的sdk
import(
...
"errors"
)
from liteblog.
2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] the request url is / 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] Handler crashed with error runtime error: invalid memory address or nil pointer dereference 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/runtime/asm_amd64.s:573 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/runtime/panic.go:502 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/runtime/panic.go:63 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/runtime/signal_windows.go:167 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] E:/GOPATH/src/github.com/jinzhu/gorm/main.go:743 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] E:/GOPATH/src/github.com/jinzhu/gorm/main.go:463 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] E:/GOPATH/src/qomo/models/note.go:37 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] E:/GOPATH/src/qomo/controllers/index.go:24 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/runtime/asm_amd64.s:573 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/reflect/value.go:447 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/reflect/value.go:308 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] E:/GOPATH/src/github.com/astaxie/beego/router.go:847 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/net/http/server.go:2694 2018/10/17 18:06:33.976 [C] [asm_amd64.s:573] C:/Go/src/net/http/server.go:1830 2018/10/17 18:06:33.977 [C] [asm_amd64.s:573] C:/Go/src/runtime/asm_amd64.s:2361 2018/10/17 18:06:33.977 [server.go:2921] [HTTP] http: multiple response.WriteHeader calls
这是新的错误
from liteblog.
错误的那段代码是,哪句?
from liteblog.
note.go文件中
func (db *DB) QueryNotesByPage(page, limit int, title string) (note []*Note, err error) { return note, db.db.Model(&Note{}).Where("title like ?", fmt.Sprintf("%%%s%%", title)).Offset((page - 1) * limit).Limit(limit).Order("updated_at DESC").Find(¬e).Error }
from liteblog.
路径都改全了吧? 尤其是 controllers->base.go .
from liteblog.
亲,这是什么原因啊,我不明白,为什么要使用github全路径
from liteblog.
我试过,我的电脑没有问题。。。可以替换。应该还是你哪儿设置的问题
from liteblog.
方便的话,能否将你的代码发给我看下。http://xianyan.hellowcloud.com/note/new,用新增文章的附件功能上传下你的代码。
from liteblog.
我的项目的地址https://gitee.com/idart/qomo,你下载下来看看
from liteblog.
from liteblog.
我在 码云上rp了,你看下
from liteblog.
好的,太谢谢你啦!!
from liteblog.
Related Issues (7)
- 提交评论时对内容转义 HOT 1
- 对链接进行转义 HOT 1
- 用户名长度限制和转义 HOT 1
- 非法访问 HOT 1
- 如何在远程服务器上进行部署 HOT 3
- 该维护了,首页500 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liteblog.