如何使用反射将数组值设置为golang中的字段?

I have a Struct with following fields

type Config struct {
        Address[]string
        Name string
}

I am reading the values for this Config from a file in JSON format

{
   "Address": ["xx.xx.xx.xx","xx.xx.xx.xx"],
   "Name":"Name"
}

I have used Reflect to identify the type and set its value to Config.I am able to set the value of Name field using func (v Value) SetString(x string) which is an inbuilt method in reflect. Is there a way to set []string values directly to a field? Please help.

You can use the json package for that (it uses reflect internally):

package main

import (
    "encoding/json"
    "fmt"
)

type Config struct {
    Address []string
    Name    string
}

var someJson = []byte(`{
   "Address": ["xx.xx.xx.xx","xx.xx.xx.xx"],
   "Name":"Name"
}`)

func main() {
    var config Config
    err := json.Unmarshal(someJson, &config)
    if err != nil {
        fmt.Println("error: ", err)
    }
    fmt.Printf("%v", config)
}