2019独角兽企业重金招聘Python工程师标准>>>

A little over two years ago, I started looking for a web framework like Django for Golang but to my surprise, I couldn’t find anything that even does the basic. My requirements were simple:

  • A standard way of creating models and database schema migration
  • Some basic UI features like foreign key, static lists, inlines and some front-end validation
  • Auto generated UI that looks good enough for prototyping a concept and could be used for production.

I remembered at that point how Django was originally created where they were looking for something like Ruby on Rails for Python and they could not find so they created Django. So for the next 13 days I started writing a prototype under the code “eadmin” with the help of other developers doing UI, Golang reflection, database, … etc. We ended up with something that works. It didn’t have any of the cool features that Django has but it works and it was blazing fast. The most important feature that we got out of that is we had a way to quickly prototype an idea and ship it on a SCB (Single Board Computer) with an ARM CPU and 128–256 MB RAM.

Fast forward two years and our basic library is a developer’s wish list. Everyone on my team contributed code and found “a missing feature” from export to Excel to a built-in image cropping! This is too cool to stay as an in-house tool and we should open source it. I asked management if they are open to the idea and weirdly they didn’t mind it. Now I have to open source it but first I have to clean our code from all product specific code and replace it with generic features that could be used instead. We also decided to rename our library to uAdmin because the name was available on Github and none of us was clever enough to come up with something as cool as Django.

what is so special about uAdmin?

  • Blazing fast
  • Can run on minimum hardware requirements
  • Pretty good security features (bcrypt hashing, 2FA)
  • Clean and sharp UI
  • Defaults for everything! but don’t worry, you can override them

So let’s jump into some code

To install uAdmin:

go get github.com/uadmin/uadmin/...

now you can start your first project:

$ mkdir -p ~/go/src/github.com/your_name/todo
$ cd ~/go/src/github.com/your_name/todo
$ uadmin prepare

Running uadmin prepare will create a few new folders for you, templates, static, … etc. You don’t really have to worry about these for now. Let start writing code. Use any editor you like to create main.go and put this code in it.

package main
import ("github.com/uadmin/uadmin""time"
)
type Todo struct {uadmin.ModelName        stringDescription string `uadmin:"html"`TargetDate  time.TimeProgress    int `uadmin:"progress_bar"`
}
func main() {uadmin.Register(Todo{})uadmin.StartServer()
}

To run this:

go build; ./todo

It will create a database and migrate your model and create a few more “system” models for authentication, permissions … etc. You should be able to check your project now at http://0.0.0.0:8080/

You can login with username admin and password admin and you will get the dashboard:

You can see that your model TODO is already on your dashboard. Open that and add a task to your todo list:

That’s it. Congrats, you have built your first app with uAdmin. Now you have to know that everything in here is customizable a we will cover some more features in part 2 of this tutorial.

转载于:https://my.oschina.net/lemonwater/blog/2872892

uAdmin the Golang Web framework相关推荐

  1. CentOS Docker安装配置部署Golang web helloworld

    目录[阅读时间:约5分钟] 一.Docker简介 二.Docker的安装与配置[CentOS环境] 三.Docker部署Golang web helloworld 四.Docker与虚拟机的区别 五. ...

  2. golang web开发框架 Beego

    1 介绍 Beego是一个开源的基于Golang的MVC框架,主要用于Golang Web开发.Beego可以用来快速开发API.Web.后端服务等各种应用. 个人开发 api类:gin 团队大项目: ...

  3. golang web php,golang 适合做web开发吗

    使用go语言来做web开发,是非常方便的.如果不使用框架,仅仅使用net/http包,也能快速开发一个web应用.但是,官方包不支持RESTful风格的API,所以我们依然还是需要选择一个框架来帮助我 ...

  4. golang web服务器_使用Go制作自己的Web服务器:快速指南

    golang web服务器 The Go programming language is well-known for having a built-in web server. In this ar ...

  5. Golang Web入门(4):如何设计API

    Golang Web入门(4):如何设计API 摘要 在之前的几篇文章中,我们从如何实现最简单的HTTP服务器,到如何对路由进行改进,到如何增加中间件.总的来讲,我们已经把Web服务器相关的内容大概梳 ...

  6. Golang Web入门(3):如何优雅的设计中间件

    Golang Web入门(3):如何优雅的设计中间件 摘要 我们上篇文章已经可以实现一个性能较高,且支持RESTful风格的路由了.但是,在Web应用的开发中,我们还需要一些可以被扩展的功能. 因此, ...

  7. Golang Web入门(2):如何实现一个RESTful风格的路由

    Golang Web入门(2):如何实现一个RESTful风格的路由 摘要 在上一篇文章中,我们聊了聊在Golang中怎么实现一个Http服务器.但是在最后我们可以发现,固然DefaultServeM ...

  8. Golang web filter 轻量级实现

    前言 golang web 通过http handle模块进行restful接口与请求处理绑定:既然用了restful每个公司或项目都会制定自己的设计原则和约束条件.在日常开发中通常会根据uri匹配规 ...

  9. 介绍一个python的新的web framework——karloop框架

    karloop是一款轻型的web framework,和tornado.webpy类似.mvc分层设计,眼下已经公布早期版本号了,使用方便, 下载地址例如以下:https://github.com/k ...

最新文章

  1. java getcolormodel_Java ColorModel.getTransparency方法代碼示例
  2. [译]GPU加持,TensorFlow Lite更快了
  3. $ionicPopup
  4. 【渝粤教育】国家开放大学2019年春季 2507学前儿童艺术教育(音乐) 参考试题
  5. java学习(163):同步方法锁
  6. 二进制和八进制表示法
  7. 转:GCC,LLVM,Clang编译器对比
  8. Helm 3 完整教程(十五):Helm 函数讲解(9)网络函数、文件路径函数、类型检查函数
  9. 医疗器械软件质量体系等
  10. 政策频发,全国区块链应用不断涌现 | 产业区块链发展周报
  11. 中山香山杯 misc write up
  12. 0.强化学习概述+policy based+value based
  13. 微信趣味地区一键设置,安排
  14. 表结构 shopnc
  15. One git command may cause you hacked(CVE-2014-9390)
  16. Compose Wheel组件。滚轮组件
  17. 电子调谐器的主要引脚及作用
  18. hiho一下 第139周 买零食
  19. Coding and Paper Letter(四十一)
  20. 微信支付回调地址 http https问题

热门文章

  1. 天大18年c语言离线作业,天大18秋C语言程序设计在线作业一辅导资料.docx-资源下载在线文库www.lddoc.cn...
  2. 前端封装接口弹出错误_项目实践:SpringBoot三招组合拳,手把手教你打出优雅的后端接口...
  3. figma下载_搬到Figma对我意味着什么
  4. 视觉设计师跟平面设计_使设计具有视觉吸引力
  5. 青海西宁市大通县非洲猪瘟疫区解除封锁
  6. HDU 4747 Mex
  7. CSS中!important的使用
  8. Hyper-V 嵌套虚拟化
  9. 前端应该掌握的网络知识(1)
  10. windows2003添加普通用户的远程桌面权限