Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate code in load #6

Closed
willsmile opened this issue Jun 9, 2020 · 1 comment
Closed

Duplicate code in load #6

willsmile opened this issue Jun 9, 2020 · 1 comment

Comments

@willsmile
Copy link
Owner

The following function have similar processes.

// LoadPlan uses for loading a test plan from a JSON file
func LoadPlan(path string) Plan {
	var plan Plan

	raw, error := ioutil.ReadFile(path)
	if error != nil {
		log.Fatal("[File Loading Error] ", error)
		os.Exit(1)
	}

	json.Unmarshal(raw, &plan)

	return plan
}

// LoadAPIStore uses for loading APIStore from a JSON file
func LoadAPIStore(path string) APIStore {
	var store APIStore

	raw, error := ioutil.ReadFile(path)
	if error != nil {
		log.Fatal("[File Loading Error] ", error)
		os.Exit(1)
	}

	json.Unmarshal(raw, &store)

	return store
}
@willsmile
Copy link
Owner Author

Duplicate but necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant