Skip to content

Commit

Permalink
Merge pull request #584 from epompeii/patch-1
Browse files Browse the repository at this point in the history
Fix typo
  • Loading branch information
jeremyandrews committed Apr 15, 2024
2 parents 4ddda5e + 859da53 commit f1e4bb9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/docs/goose-book/src/getting-started/creating.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ async fn main() -> Result<(), GooseError> {

The `#[tokio::main]` at the beginning of this example is a Tokio macro necessary because Goose is an asynchronous library, allowing (and requiring) us to declare the `main()` function of our load test application as `async`.

If you're new to Rust, `main()`'s return type of `Result<(), GooseError>` may look strange. It essentially says that `main` will return nothing (`()`) on success, and will return a `GooseError` on failure. This is helpful as several of `GooseAttack`'s methods can fail, returning an error. In our example, `initialize()` and `execute()` each may fail. The `?` that follows the method's name tells our program to exit and return an error on failure, otherwise continue on. Note that the `.execute()` method is asynchronous, so it must be followed with `.await`, and as it can return an error it alsos has a `?`. The final line, `Ok(())` returns the empty result expected on success.
If you're new to Rust, `main()`'s return type of `Result<(), GooseError>` may look strange. It essentially says that `main` will return nothing (`()`) on success, and will return a `GooseError` on failure. This is helpful as several of `GooseAttack`'s methods can fail, returning an error. In our example, `initialize()` and `execute()` each may fail. The `?` that follows the method's name tells our program to exit and return an error on failure, otherwise continue on. Note that the `.execute()` method is asynchronous, so it must be followed with `.await`, and as it can return an error it also has a `?`. The final line, `Ok(())` returns the empty result expected on success.

And that's it, you've created your first load test! Read on to see how to run it and what it does.

0 comments on commit f1e4bb9

Please sign in to comment.