Increment
Extend the Hello World example to support incrementing a number by clicking on a button.
Categories:
In the last section, you built a simple app that says, “Hello, World!” In this section, you will add to that app by creating a button that increments a label. To do that, you need to add the following code after the “Hello, World!” label:
Then, run go build
and ./myapp
if you are on MacOS or Linux and ./myapp.exe
if you are on Windows. This should create a window similar to the last one, except with a new label and button. Each time you click the Increment
button, the number in the new label should increase by 1. If you click the button 7 times, the app should look like this:
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified January 22, 2024: removed old deps from go mod (0b4edcc)