Skip to content

Latest commit

 

History

History
96 lines (83 loc) · 4.78 KB

README.md

File metadata and controls

96 lines (83 loc) · 4.78 KB

Examples

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.

gobash

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 library
  • structs_ex - Introduces structs and constructors
  • anonymous_struct_ex - Introduces anonymous structs
  • methods_ex - Introduces methods
  • error_ex - Introduces ctx used to write and print error messages
  • result_ex - Introduces Result struct that can be used to return a value from a function / method
  • to_string_ex - Illustrates the default to_string method and overriding
  • to_json_ex - Illustrates the default to_json method and overriding
  • list_ex - Introduces List data structures
  • map_ex - Introduces Map data structure
  • shapes_ex - Combines structs, methods, and data structures
  • linked_list_ex - Revisits structs and methods with a random example
  • regexp_ex - Illustrates use of the regular expression API
  • flags_ex - Illustrates parsing of command line flags
  • flags_details_ex - Illustrates command line parsing with a more concrete example
  • strings_ex - Illustrates the string API
  • file_ex - Illustrates the file API
  • mutex_counter_ex - Shows a way to use the Mutex struct for synchronization
  • wait_group_ex - Shows a way to use WaitGroup struct to wait for sub processes
  • chan_ex - Introduces the Chan struct for process communication
  • binary_trees_ex - Demos tree walk using the Chan struct
  • web_server_ex - Illustrates a simple web server implementation
  • log_ex - Illustrates log API
  • text_menu_ex - Demos text-based menu
  • text_spinner_ex - Demos text-based spinner
  • text_progress_ex - Demos text-based progress bar
  • whiptail_ex - Demos the approach to use whiptail windows/UI
  • user_ex - Illustrates API for accessing user info
  • visitor_ex - Demos the accept / visit pattern
  • template_ex - Demos recommended (but not required) workflow

Playground

Below is the list of examples matching those available in the Go playground. Note that not each example uses/needs gobash.

Rewrites

We wrote a couple of existing scripts using bash with the gobash library. Some are included below.

A Tour of Shell Scripting

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).