go-admingo-admin
  • Guide
  • Development
    • Advanced
    • Commands
  • Advanced
  • Help
  • GitHub
  • Changelog
⌘ K
Introduction
Quick Start
Go Environment
Go Modules
Environment Variables
Node Environment
IDE Setup
Conventions
Deployment
FAQ
Last updated:
Open-source MIT Licensed | Copyright © 2020-present
Powered by go-admin-team

TABLE OF CONTENTS

‌
‌
‌
‌

CGO Issues

ERROR

CGO issues on Windows

Building on Windows can hit CGO-related errors:

bash
E:\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec /missing-cc: exec: "/missing-cc": file does not exist

or

bash
D:\Code\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec gcc: exec: "gcc": executable file not found in %PATH%

How to fix cgo: exec gcc: ...

Error: requires at least one arg

If starting the project prints Error: requires at least one arg, at least one argument is required.

Run ./go-admin -h to see the available commands.

Output looks like this:

macOS: gyp: No Xcode or CLT version detected!

The problem

bash
> fsevents@1.2.12 install /Users/zhangwenjian/Code/go-test/go-admin-ui/node_modules/fsevents
> node-gyp rebuild
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/zhangwenjian/Code/go-test/go-admin-ui/node_modules/fsevents
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

The fix

bash
sudo xcode-select --install

If it was installed before, reset it with:

SUCCESS

This happens after a macOS upgrade strips the Xcode CLI tools — reinstalling them with the command above fixes it.

bash
sudo xcode-select --reset

mysql connect error %v dial tcp 127.0.0.1:3306: connect: connection refused

The problem

bash
$ ./go-admin
2020/04/07 14:21:14 root:password@tcp(127.0.0.1:3306)/dbname
2020/04/07 14:21:14 mysql connect error %v dial tcp 127.0.0.1:3306: connect: connection refused

The fix

Fix the database settings in the config file, located at config/settings.yml. The relevant part to change:

bash
database:
# database type: mysql, sqlite3, postgres
driver: mysql
# connection string; the mysql default shown here includes charset=utf8&parseTime=True&loc=Local&timeout=1000ms
source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms

el-tree's setCheckedKeys Throws an Error

The problem

bash
"TypeError: Cannot read property 'setCheckedKeys' of undefined"

Why

The tree's data is fetched asynchronously; by the time it's assigned, the component hasn't finished rendering yet, so $refs doesn't have the instance to hand back.

The fix

Call it inside $nextTick, after the DOM has actually updated:

js
roleMenuTreeselect(roleId).then(response => {
this.menuOptions = response.data.menus
this.$nextTick(() => {
this.$refs.menuTree.setCheckedKeys(checkedKeys)
})
})

The full version is in src/views/admin/sys-role/index.vue.

"Sorry, you don't have access to this API, please contact your administrator"

The problem

The fix

Use this log output to work out what permission is missing and configure accordingly.

github.com/mattn/go-sqlite3 cgo: exec gcc: ******

The problem

This shows up on Windows:

bash
E:\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec /missing-cc: exec: "/missing-cc": file does not exist

or

bash
D:\Code\go-admin>go build
# github.com/mattn/go-sqlite3
cgo: exec gcc: exec: "gcc": executable file not found in %PATH%

The fix

Download the archive matching your system version:

https://sourceforge.net/projects/mingw-w64/files/mingw-w64/

INFO

⚠️ Note

This was tested against MinGW-W64 GCC-8.1.0. If your version differs, download and configure the build matching your OS.

64-bit systems, download this build:

x86_64-posix-seh

32-bit systems, download this build:

x86_64-win32-seh

Extract the archive and add its bin directory to the PATH environment variable.

INFO

When setting the Windows environment variable, the bin directory's path must not contain spaces.

For example, a path like C:/go go/bin won't work.

For example, C:/go_go/bin ✔️ works fine.

Configured Redis, But the Service Won't Start

The current version's cache and queue both support Redis — see Cache and Queue for how to configure it (Chinese only for now).

If the service fails to start after configuring it, it's almost always a connection parameter — a misconfigured redis section now fails the service outright at startup, rather than silently falling back to the in-memory implementation the way older versions did (that was the behaviour tracked in issue #846, since fixed). Check, in order:

  1. Whether addr is reachable — can you redis-cli -h <addr> ping from that machine?
  2. Whether password is correct;
  3. Whether the db index is within the Redis instance's configured databases count.

The startup log prints the specific connection error, which is enough to pinpoint it without guessing.

Token Never Expires / Login Doesn't Ask for a Captcha

Check application.mode in the config file.

Set to dev, login skips captcha verification, and the JWT lifetime is forced to 876,010 hours (about 100 years) — jwt.timeout has no effect in this mode. This is meant to make local development convenient; production must be set to prod.

See Config Reference for the full effect of each value.

Config Changes Aren't Taking Effect

Check, in order:

  1. Whether -c at startup points at the file you're actually editing — without -c, config/settings.yml is read by default;
  2. Whether that config item is actually read by the program at all. The locker block, for instance, has no corresponding struct field in the current version, so anything written there is simply never parsed;
  3. Whether the service was restarted. Config is loaded at startup — a change needs a restart to take effect.

WARNING

Where to get help:

If anything in this guide is unclear, please open an issue.