云计算百科
云计算领域专业知识百科平台

GO+RabbitMQ+Gin+Gorm+docker 部署 demo

更多个人笔记见: (注意点击“继续”,而不是“发现新项目”) github个人笔记仓库 https://github.com/ZHLOVEYY/IT_note gitee 个人笔记仓库 https://gitee.com/harryhack/it_note 个人学习,学习过程中还会不断补充~ (后续会更新在github上)

文章目录

    • 目录
    • 准备
    • 运行
    • 测试
        • postman
        • 检查容器
  • 链接:项目连接,完整项目代码仓库下载
  • https://gitee.com/harryhack/it_note/tree/main/%E5%90%8E%E7%AB%AF%E7%AC%94%E8%AE%B0/%E5%B8%B8%E7%94%A8Web%E6%8A%80%E6%9C%AF/RabbitMQ

目录

demo 目录

post-platform/
├── Dockerfile # Go 应用 Dockerfile
├── docker-compose.yml # Docker Compose 配置
├── main.go # 主程序(Gin + RabbitMQ 消费者)
├── db/
│ └── db.go # 数据库连接
├── models/
│ └── post.go # 帖子模型
├── rabbitmq/
│ └── consumer.go # RabbitMQ 消费者逻辑
├── go.mod
└── go.sum

准备

  • docker
  • docker-compose

运行

docker-compose up –build 然后在 docker 中可以检查容器情况

测试

postman
  • http://localhost:8080/ping GET
  • http://localhost:8080/posts POST

{
"title": "My First post",
"content": "Hello, world!"
}

检查容器
  • docker exec -it fortest-mysql-1 mysql -u root -p
    • 然后输入密码,检查数据库 use posts_db , select * from posts
赞(0)
未经允许不得转载:网硕互联帮助中心 » GO+RabbitMQ+Gin+Gorm+docker 部署 demo
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!