We provide a number of examples in bash that use gobash
, as well as
an intro tour into shell scripting if you have no prior experience.
Each of the following examples uses some features/functions from
gobash
. The examples are sorted such that each might build on an
earlier example. Checking them in order is the recommended, but
depending on your interest that might not be the case.
hello_world_ex
- Iterates over some key points related to the librarystructs_ex
- Introduces structs and constructorsanonymous_struct_ex
- Introduces anonymous structsmethods_ex
- Introduces methodserror_ex
- Introducesctx
used to write and print error messagesresult_ex
- IntroducesResult
struct that can be used to return a value from a function / methodto_string_ex
- Illustrates the defaultto_string
method and overridingto_json_ex
- Illustrates the defaultto_json
method and overridinglist_ex
- IntroducesList
data structuresmap_ex
- IntroducesMap
data structureshapes_ex
- Combines structs, methods, and data structureslinked_list_ex
- Revisits structs and methods with a random exampleregexp_ex
- Illustrates use of the regular expression APIflags_ex
- Illustrates parsing of command line flagsflags_details_ex
- Illustrates command line parsing with a more concrete examplestrings_ex
- Illustrates thestring
APIfile_ex
- Illustrates thefile
APImutex_counter_ex
- Shows a way to use theMutex
struct for synchronizationwait_group_ex
- Shows a way to useWaitGroup
struct to wait for sub processeschan_ex
- Introduces theChan
struct for process communicationbinary_trees_ex
- Demos tree walk using theChan
structweb_server_ex
- Illustrates a simple web server implementationlog_ex
- Illustrates log APItext_menu_ex
- Demos text-based menutext_spinner_ex
- Demos text-based spinnertext_progress_ex
- Demos text-based progress barwhiptail_ex
- Demos the approach to usewhiptail
windows/UIuser_ex
- Illustrates API for accessing user infovisitor_ex
- Demos the accept / visit patterntemplate_ex
- Demos recommended (but not required) workflow
Below is the list of examples matching those available in the Go
playground. Note that not each example uses/needs gobash
.
hellow_world_ex
clear_screen_ex
http_server_ex
sleep_ex
test_function_ex
concurrent_pi_ex
ring_do_ex
ring_len_ex
ring_link_ex
ring_move_ex
ring_next_ex
ring_prev_ex
ring_unlink_ex
list_ex
We wrote a couple of existing scripts using bash with the gobash
library. Some are included below.
A tour of shell scripting. These examples do not necessarily use
gobash
. A few examples are inspired by the sequence in the Go
playground (in which case we provide the link to the original example
inside the file).