github.com/searKing/golang/go@v1.2.117/encoding/json/read.go (about)

     1  // Copyright 2022 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package json
     6  
     7  import (
     8  	"encoding/json"
     9  	"os"
    10  )
    11  
    12  func ReadConfigFile(name string, v any) error {
    13  	data, err := os.ReadFile(name)
    14  	if err != nil {
    15  		return err
    16  	}
    17  	return json.Unmarshal(data, v)
    18  }