# IDE 开发配置

# goland 配置

众多 IDE 里边,推荐使用 goland IDE进行调试

首先我们启动 Goland , 点击 Open Project,下图红框圈选部分;

选择 go-admin 存放的路径,找到并打开;

# 配置 GOPORXY

然后选择Goland > Preferences

# 添加运行或调试配置

# 添加 migrate 配置

  1. 打开Edit Configurations

  1. 选择 + > go build

  1. 按照下图所示进行配置,注意:填写 Program argumentsmigrate -c=config/settings.dev.yml,完成之后点击保存

  1. 修改数据库

  1. 初使化

# 添加 server 配置

  1. 打开Edit Configurations

  2. 选择 + > go build

  1. 按照下图所示进行配置,注意:填写 Program argumentsserver -c=config/settings.dev.yml,完成之后点击保存

  1. 启动 debug

TIP

特别感谢 海马同学 的支持,对文档的维护起到了至关重要的角色

# VSCode

有好多朋友反馈需要在 vscode 环境下进行开发,那么提供一份完成的调试配置,供大家参考使用;

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "go build go-admin",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "port": 8000,
      "host": "127.0.0.1",
      "program": "${workspaceRoot}",
      "env": {
        "GOPATH": "/Users/zhangwenjian/go"
      },
      "args": ["server", "-c", "config/settings.dev.yml"]
    },
    {
      "name": "go migrate go-admin to db",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "env": {
        "GOPATH": "/Users/zhangwenjian/go"
      },
      "args": ["migrate", "-c", "config/settings.dev.yml"]
    },
    {
      "name": "go migrate go-admin to file",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "env": {
        "GOPATH": "/Users/zhangwenjian/go"
      },
      "args": ["migrate", "-c", "config/settings.dev.yml", "-g", "true"]
    },
    {
      "name": "go version goadmin",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "env": {
        "GOPATH": "/Users/zhangwenjian/go"
      },
      "args": ["version"]
    }
  ]
}
上次更新: 2021/4/12 下午4:35:36