// Load loads the profiles from the context file. If the context file doesn't exist
// it will return an empty context object.
Load loads the profiles from the context file. If the context file doesn't exist
it will return an empty context object.
// Load loads the profiles from the context file . If the context file doesn ' t exist // it will return an empty context object .
func (c *File) Load() (*Context, error) {
	file, err := c.Location()
	if err != nil {
		return nil, err
	}
	_, err = os.Stat(file)
	if os.IsNotExist(err) {
		return nil, err
	}
	if err != nil {
		return nil, fmt.Errorf(errorFormat, "unable to check if context file exists", err)
	}
	data, err := ioutil.ReadFile(file)
	if err != nil {
		return nil, fmt.Errorf(errorFormat, "unable to read context file", err)
	}
	var ctx Context
	err = json.Unmarshal(data, &ctx)
	if err != nil {
		return nil, fmt.Errorf(errorFormat, "unable to parse contexts", err)
	}
	return &ctx, nil
}
func ( c * File ) Load ( ) ( * Context , error ) { file , err := c . Location ( ) if err != nil { return nil , err } _ , err = os . Stat ( file ) if os . IsNotExist ( err ) { return nil , err } if err != nil { return nil , fmt . Errorf ( errorFormat , " " , err ) } data , err := ioutil . ReadFile ( file ) if err != nil { return nil , fmt . Errorf ( errorFormat , " " , err ) } var ctx Context err = json . Unmarshal ( data , & ctx ) if err != nil { return nil , fmt . Errorf ( errorFormat , " " , err ) } return & ctx , nil }
Load loads the profiles from the context file.
Load loads the profiles from the context file .
// #nosec G304