Go Pages

Dot Net Perls has example pages for many languages, with explanations and code side by side (for easy understanding).


Use maps to provide lookups from keys to values. Get values and delete them.Golang Map Examples

2D slice, array.

Use 2D slices and arrays. Nest slices and arrays to create multiple dimensions.Golang 2D Slices and Arrays


Use arrays with int and string elements. Iterate over an array with a for-loop.Golang Array Examples


Review built-in functions in Golang. See examples of how these built-ins are used.Golang Built In Functions


Use byte slices and the bytes package. Manipulate, test and benchmark byte slices.Golang Bytes: Slices and Methods


Use the const and var keywords. Generate constants with the iota enumerator.Golang Const, Var Examples: Iota

Conversion, strconv.

Cast numeric types and convert values to strings. Perform map and slice conversions.Golang strconv, Convert Int to String


Use the encoding-cvs package. Call NewReader and Read to read records.Golang csv Examples: NewReader and ReadAll

File, bufio.

Use bufio, NewScanner, Scan and Text to read the lines of a file. Call ioutil.ReadAll.Golang Read Text File: bufio, ioutil.ReadAll Examples


Use the flag package for command-line arguments. Pass ints and String arguments.Golang flag, Command Line Int, String Examples

Fmt, printing.

Use the fmt package to write values to the console. Call Println and Sprintf.Golang fmt.Println, Sprintf: Console Programs


Use the for-loop to iterate through numbers. Look at foreach and while loops.Golang for Loop Examples: Foreach and While


Create methods with the func keyword. See arguments and multiple return values.Golang Func Examples


Use if, else if and else statements to test values. See correct syntax.Golang If, Else Statements


Use the encoding/json library to convert Go objects to JSON. Call Marshal and Unmarshal.Golang JSON Example: Marshal, Unmarshal


Use the len built-in function to get string lengths. Len supports arrays, slices and maps.Golang Len (String Length)


Perform mathematical computations with the math module. Call math.Abs and math.Pow.Golang Math Module: math.Abs, Pow


Use the strconv package and the ParseInt and Atoi funcs. Convert strings to ints.Golang ParseInt Examples: Convert String to Int


Use the rand package and generate random numbers. Call rand.Int and Seed.Golang rand, crypto: Random Number Generators


Use the regexp package for regular expressions. Call MatchString and compile patterns.Golang Regexp Examples: MatchString, MustCompile

Remove duplicates.

Use maps, and slices, to remove duplicate elements from slices of ints and strings.Golang Remove Duplicates From Slice


Use strings.Replace, in the strings package, to modify strings. Call NewReplacer.Golang Replace String Examples: Replacer, NewReplacer


Use slices to store elements. Call the append, cap and make functions.Golang Slice Examples (append, cap and make)


Use the sort package and sort elements. Invoke the Strings and Sort methods.Golang Sort Slice: Len, Less, Swap in Interface


Use Split from the strings package. Call SplitAfter and SplitN to separate strings.Golang Split Examples (SplitAfter, SplitN)


Explore the strings package. The methods in strings create, test and modify string data.Golang Strings


Create structs to store fields and methods together. Use the new keyword.Golang Struct Examples: Types and Pointers

Substring, string slice.

Use string slice syntax to take substrings. Take rune slices to handle more characters.Golang Substring Examples (Rune Slices)


Use switch, with expressions and case lists, to test variables and return values.Golang Switch Examples: case, break and fallthrough


Use the time package to get and modify times. Get Now, Year, Month and Day.Golang Time: Now, Parse and Duration
Dot Net Perls
© 2007-2019 Sam Allen. All rights reserved. Written by Sam Allen,