日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

uAdmin the Golang Web framework

發布時間:2023/12/6 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 uAdmin the Golang Web framework 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。