Skip to content

Commit 5668b12

Browse files
authored
docs(config_yaml): clarify DUBBO_GO_CONFIG_PATH resolution (#1097)
DUBBO_GO_CONFIG_PATH is resolved against the running process's working directory, but the README only showed a relative form (`../conf/dubbogo.yml`) that requires cd'ing into the `cmd` directory. Users who run the more idiomatic `go run ./config_yaml/go-server/cmd/...` from the repo root see dubbo.Load() panic with no clear hint about why. Update both README.md and README_zh.md to: - Recommend running from the repo root with an absolute path built via `$(pwd)/...`, which works regardless of where the user is. - Keep the original cd + relative path form as an alternative. - Add an explicit note explaining how the variable is resolved so users can debug their own setup. Closes #1083
1 parent 3ac38cf commit 5668b12

2 files changed

Lines changed: 50 additions & 4 deletions

File tree

config_yaml/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,38 @@ cd path_to_dubbogo-sample/config_yaml/proto
3131
protoc --go_out=. --go-triple_out=. ./greet.proto
3232
```
3333
### Server
34+
35+
Run from the repository root:
36+
3437
```bash
38+
export DUBBO_GO_CONFIG_PATH="$(pwd)/config_yaml/go-server/conf/dubbogo.yml"
39+
go run ./config_yaml/go-server/cmd/main.go
40+
```
41+
42+
Or, if you prefer to `cd` into the `cmd` directory first, the relative path also works:
43+
44+
```bash
45+
cd config_yaml/go-server/cmd
3546
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
36-
cd path_to_dubbogo-sample/config_yaml/go-server/cmd
3747
go run .
3848
```
49+
50+
> **Note**: `DUBBO_GO_CONFIG_PATH` is resolved against the working directory of the running process, so a relative value like `../conf/dubbogo.yml` only works when you launch the program from the `cmd` directory. Use an absolute path (as in the first example) to avoid this constraint.
51+
3952
### Client
53+
54+
Run from the repository root (after the server is up):
55+
56+
```bash
57+
export DUBBO_GO_CONFIG_PATH="$(pwd)/config_yaml/go-client/conf/dubbogo.yml"
58+
go run ./config_yaml/go-client/cmd/main.go
59+
```
60+
61+
Or, with `cd`:
62+
4063
```bash
64+
cd config_yaml/go-client/cmd
4165
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
42-
cd path_to_dubbogo-sample/config_yaml/go-client/cmd
4366
go run .
4467
```
4568

config_yaml/README_zh.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,38 @@ cd path_to_dubbogo-sample/config_yaml/proto
3232
protoc --go_out=. --go-triple_out=. ./greet.proto
3333
```
3434
### Server
35+
36+
在仓库根目录下运行:
37+
3538
```bash
39+
export DUBBO_GO_CONFIG_PATH="$(pwd)/config_yaml/go-server/conf/dubbogo.yml"
40+
go run ./config_yaml/go-server/cmd/main.go
41+
```
42+
43+
或者,先 `cd``cmd` 目录再运行(用相对路径也可以):
44+
45+
```bash
46+
cd config_yaml/go-server/cmd
3647
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
37-
cd path_to_dubbogo-sample/config_yaml/go-server/cmd
3848
go run .
3949
```
50+
51+
> **注意**`DUBBO_GO_CONFIG_PATH` 是相对于程序运行时的工作目录解析的,所以 `../conf/dubbogo.yml` 这种相对路径只有在 `cmd` 目录下启动程序时才有效。如果想从其他目录启动,建议使用上面那种绝对路径。
52+
4053
### Client
54+
55+
在仓库根目录下运行(服务端启动后):
56+
57+
```bash
58+
export DUBBO_GO_CONFIG_PATH="$(pwd)/config_yaml/go-client/conf/dubbogo.yml"
59+
go run ./config_yaml/go-client/cmd/main.go
60+
```
61+
62+
或者先 `cd`
63+
4164
```bash
65+
cd config_yaml/go-client/cmd
4266
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml"
43-
cd path_to_dubbogo-sample/config_yaml/go-client/cmd
4467
go run .
4568
```
4669

0 commit comments

Comments
 (0)