[项目推荐] goxygen 现代化的 Web 应用生成器(Go + React + MongoDB)

Go

在几秒钟内使用 Go,React和 MongoDB 生成一个完整的 Web 项目

Goxygen 的主旨在于在新建一个新的项目的时候,帮你节省时间。他创建应用程序的框架,并帮你完成所有配置。你可以立刻开始实现业务逻辑。 Goxygen 生成后端 Go 代码,将其与前端React组件连接,为应用程序提供一个 Dockerfile,并且创建 docker-compose 文件,以便在开发和生产环境中运行它。

怎么使用

你需要有 Go 1.11 或者更新的版本在你的机器上。

go get -u github.com/shpota/goxygen
go run github.com/shpota/goxygen init my-app

这会在 my-app 目录生成一个项目。

生成的项目已经可以使用 docker-compose 运行了:

cd my-app
docker-compose up

构建完成后,这个应用就可以在 http://localhost:8080 上面访问了。

可以在自述文件中找到有关如何处理生成的项目的更多详细信息。

Go

Go

Go

项目的结构

my-app
├── server                   # Go project files
│   ├── db                   # MongoDB communications
│   ├── model                # domain objects
│   ├── web                  # REST APIs, web server
│   ├── server.go            # the starting point of the server
│   └── go.mod               # server dependencies
├── webapp                    
│   ├── public               # icons, static files, and index.html
│   ├── src                       
│   │   ├── App.js           # the main React component
│   │   ├── App.css          # App component-specific styles
│   │   ├── index.js         # the entry point of the application          
│   │   └── index.css        # global styles
│   ├── package.json         # front end dependencies
│   ├── .env.development     # holds API endpoint for dev environment
│   └── .env.production      # API endpoint for prod environment
├── Dockerfile               # builds back end and front end together
├── docker-compose.yml       # prod environment deployment descriptor
├── docker-compose-dev.yml   # runs local MongoDB for development needs
├── init-db.js               # creates a MongoDB collection with test data
├── .dockerignore            # specifies files ignored in Docker builds
├── .gitignore
└── README.md                # guide on how to use the generated repo

为了简单起见,单元测试或示例组件文件都不包含在此。

依赖项

Goxygen 生成一个项目的基本机构,并且不会强制你使用指定的工具。这就是问什么它不会让你的项目增加不必要的依赖的原因。仅仅需要的两个依赖是后端的 mongo-go-driver 和前端的 axios 。

本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。

原文地址:https://github.com/Shpota/goxygen

译文地址:https://learnku.com/go/t/41082

本文为协同翻译文章,如您发现瑕疵请点击「改进」按钮提交优化建议
讨论数量: 1

不错的工具哈! 赖人必备。 :grin:

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!