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

feat: add missing return to README example #154

Merged
merged 3 commits into from
May 29, 2021
Merged

feat: add missing return to README example #154

merged 3 commits into from
May 29, 2021

Conversation

g1stavo
Copy link
Contributor

@g1stavo g1stavo commented Feb 26, 2021

The compiler return a missing return error in this README code example:

	// Pass in test case. This is the component that makes the external HTTP call
	var test = func() (err error) {
		u := fmt.Sprintf("http://localhost:%d/foobar", pact.Server.Port)
		req, err := http.NewRequest("GET", u, strings.NewReader(`{"name":"billy"}`))
		if err != nil {
			return err
		}

		// NOTE: by default, request bodies are expected to be sent with a Content-Type
		// of application/json. If you don't explicitly set the content-type, you
		// will get a mismatch during Verification.
		req.Header.Set("Content-Type", "application/json")
		req.Header.Set("Authorization", "Bearer 1234")

		if _, err = http.DefaultClient.Do(req); err != nil {
			return err
		}
	}

Just added a return after the last if. Also omitted return values, as the function has a named return err error.

@g1stavo g1stavo closed this Feb 26, 2021
@g1stavo g1stavo changed the title Add missing return to README example feat: add missing return to README example Feb 26, 2021
@g1stavo g1stavo reopened this Feb 26, 2021
@mefellows mefellows merged commit bd39399 into pact-foundation:master May 29, 2021
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

Successfully merging this pull request may close these issues.

2 participants