最近想找几个基于Go语言开发的简单的开源项目学习下,分享给大家,github上有心人的收集的awesome-go项目集锦:github地址
发现一个Qor项目:
Qor 是基于 Golang 开发的的CMS 一系列工具库,基于 Qor可以快速搭建网站的后台管理系统。
Qor 的工作库包含:
在Qor项目(地址)的readme中还提供中外两个聊天室,不懂的问题都可以尽情问,中文聊天室,英文聊天室,还写了一个demo购物网站,对应源码也在github上(https://github.com/qor/qor-example)。学习一个项目,就是先把项目跑起来看看效果,golang也是刚开始了解,花了两天,简单记录下踩过的坑~
golang环境搭建这里就不介绍了,可以看前面的windows下Go Web编程系列。步骤如下:
进入src源码目录下,md github.com\qor创建qor仓库,git init初始化,git clone https://github.com/qor/qor-example.git等下下载完
创建数据库(此处用navica界面创建的):
运行主程序(此处有很多问题):
问题1:"cloud.google.com/go/compute/metadata"包找不到,在src目录下按照错误提示路径创建后下载,git clone https://github.com/googleapis/google-cloud-go,然后修改目录名(把google-cloud-go里面的同名目录剪切到上一级替换掉google-cloud-go并把google-cloud-go改为go目录,见下图3)。
问题2:"D:\\mygo\\src\\github.com\\unrolled\\render" is not using a known version control system说明render不在版本控制,之前是下载的zip文件,所以删除render重新git clone git clone https://github.com/unrolled/render.git
net包也报过不在版本控制,同样使用git clone https://github.com/golang/net.git 下载
下面go get -u安装项目所需依赖,go run main.go主程序运行起来:
主程序运行起来发现config/application.example.yml,config/smtp.example.yml,config/database.example.yml几个配置文件找不到,将其example.去掉即可。
阅读README.md,再打开一个cmd执行Generate sample data
问题:执行脚本说faker包找不到,进入src\github.com 后md azumads创建报错所说的路径,cd azumads后 git clone https://github.com/azumads/faker.git
第二步骤看出程序监听7000端口,访问web:http://localhost:7000/,效果如下:
- Users:http://localhost:7000/api/users.json
- User 1:http://localhost:7000/api/users/1.json
- User 1‘s Orders:http://localhost:7000/api/users/1/orders.json
- User 1‘s Order 1:http://localhost:7000/api/users/1/orders/1.json
- User 1‘s Order 1‘s Items:http://localhost:7000/api/users/1/orders/1/items.json
- Orders:http://localhost:7000/api/orders.json
- Products:http://localhost:7000/api/products.json
问题1:RESTful API标记金色的3个page not found。
问题2:基础界面出来了,大部分按钮可以触发,但是MEN WOMEN KIDS分类点击后跳转到了空白页,golang不熟,这两个问题后续代码跟进下,如果有小伙伴跑这个项目没问题,希望能给我点帮助~。~
golang开源项目qor快速搭建网站qor-example运行实践
原文:https://www.cnblogs.com/NolaLi/p/10643813.html