Viper: Viper How to Read a Environment Array Variable

Created on 13 Jun 2019  路  2Comments  路  Source: spf13/viper

how to read a array of values with single key in go lang

Linux export a variable to environment

export key=(abc def sos ded)

how to read this in viper

Most helpful comment

You will have to write your own parsing logic.

You can:

  • use viper.GetString and further parse the string value
  • use viper.UnmarshalKey and do the same
  • use decode hooks in mapstructure

Hope that helps

All 2 comments

You will have to write your own parsing logic.

You can:

  • use viper.GetString and further parse the string value
  • use viper.UnmarshalKey and do the same
  • use decode hooks in mapstructure

Hope that helps

thank you @sagikazarmark it works

Was this page helpful?
0 / 5 - 0 ratings