DMarlon Studio

Basic Go course

From scratch: everything you need to write your first programs. In DMarlon Studio, Go is the server of the Web (Go) target: you design the screens and the studio generates the Go server that serves them.

Start
  1. 1Hello, worldWrite your first Go program: package main, the main function and fmt.Println to show text and numbers in the console.Lesson 1
  2. 2Variables and typesStore data in Go variables with var and :=, meet the basic types (int, float64, string and bool) and the zero value of each one.Lesson 2
  3. 3Constants and arithmeticUse constants and iota in Go, calculate with + - * / and %, and convert between int and float64 so you keep the decimals.Lesson 3
  4. 4Strings and PrintfJoin strings with + and format output in Go with fmt.Printf and fmt.Sprintf: the %s, %d, %.2f, %v and %q verbs, and column widths.Lesson 4
  5. 5Reading inputRead lines from the keyboard in Go with bufio.Scanner and turn them into numbers with strconv.Atoi and strconv.ParseFloat to do maths.Lesson 5
  6. 6If and elseMake decisions in Go with if, else if and else, combine conditions with &&, || and !, and use the if statement's init part.Lesson 6
  7. 7Choosing with switchChoose between several cases with switch in Go: several values per case, default, switch with no expression, init statement and fallthrough.Lesson 7
  8. 8For loopsRepeat code in Go with for, the language's only loop: the classic form, as a while, with no condition at all, break and continue.Lesson 8
  9. 9ArraysStore several values of one type in a Go array: fixed length, indexes, len, looping with for, copying on assignment and comparing with ==.Lesson 9
  10. 10SlicesWork with slices in Go, the lists that grow: append, len, cap, make and s[a:b] slicing that shares memory with the original.Lesson 10
  11. 11MapsStore key-value pairs in a Go map: adding, reading with ok, delete and len, and printing it in the same order every time with sort.Strings.Lesson 11
  12. 12Functions and multiple resultsWrite Go functions with parameters and a result type, return several values at once and use named results.Lesson 12
  13. 13Errors as valuesTreat errors as values in Go: create them with errors.New and fmt.Errorf, check them with if err != nil and recognise them with errors.Is.Lesson 13
  14. 14StructsGroup related data into a Go struct: fields, literals by name or by order, %+v, copies and slices of structs.Lesson 14
  15. 15MethodsAdd methods to your own Go types: value and pointer receivers, and the String() method that decides how a value is printed.Lesson 15
  16. 16PointersUnderstand pointers in Go: & to get an address, * to reach the value, functions that change the original, and nil.Lesson 16
  17. 17The strings and strconv packagesWork with text in Go using the strings package (Split, TrimSpace, Join, Contains, Replace) and convert text and numbers with strconv.Lesson 17
  18. 18Looping with rangeLoop over slices, maps and strings in Go with for and range: index and value, keys sorted with sort.Strings, and runes for characters.Lesson 18
  19. 19Writing and reading filesWrite and read text files in Go with the os package: WriteFile, OpenFile to append, Open with bufio.Scanner, and defer to close.Lesson 19
  20. 20Project: a shop inventoryThe final project of the basic Go course: a shop inventory built with structs, methods, errors, slices, loops and Printf.Lesson 20