dongzhuo5425 2015-08-21 20:38
浏览 105

app.conf和环境变量旁边的外部配置,用于revel go框架

I have read revel app.conf manual for custom configuration and environment variables. however I couldn't find way to use additional external configuration along with app.conf.

My goal is to achieve external configuration file in addition to internal app.conf. Let's say creating a product called example and example product maintains it's sensible defaults with app.conf (not exposing to end user) instead product exposes config attributes via example.conf (default location could be /etc/example/example.conf) for product users.

For example: http config field from app.conf

http.addr =
http.port = 9000

extend it to example.conf

http.addr =
http.port = 9000

[database]
host = "localhost"
port = 8080
user = "username"
password = "password"
# etc...

Then I read example.conf during an application start use values also apply values on top of app.conf (overriding). Finally revel server starts!

How to achieve this goal with revel go framework?

  • 写回答

2条回答 默认 最新

  • dongqi0644 2015-08-21 21:11
    关注

    It appears you are working against the design of the app.conf. It is already setup to be sectioned, for example all this is in a single app.conf file

    [dev]
    results.pretty = true
    watch = true
    http.addr = 192.168.1.2
    
    [test]
    results.pretty = true
    watch = true
    http.addr = 192.168.1.22
    
    [prod]
    results.pretty = false
    watch = false
    http.addr = 192.168.1.100
    

    you can launch 3 different scenarios by using three different command line options

    revel run bitbucket.org/mycorp/my-app dev
    
    revel run bitbucket.org/mycorp/my-app test
    
    revel run bitbucket.org/mycorp/my-app prod
    

    I know this is not exactly what your goal is but you can acheive a similar result.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算