<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Toul</title>
    <description>The latest articles on DEV Community by Toul (@toul-nyc).</description>
    <link>https://dev.to/toul-nyc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F590046%2Fe1c1fbff-b80e-48a3-9fe8-4fd1a240a40e.png</url>
      <title>DEV Community: Toul</title>
      <link>https://dev.to/toul-nyc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toul-nyc"/>
    <language>en</language>
    <item>
      <title>Get Automate the Boring Stuff with GO (e-book PDF)</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Sat, 16 Nov 2024 17:47:05 +0000</pubDate>
      <link>https://dev.to/toul-nyc/get-automate-the-boring-stuff-with-go-e-book-pdf-995</link>
      <guid>https://dev.to/toul-nyc/get-automate-the-boring-stuff-with-go-e-book-pdf-995</guid>
      <description>&lt;p&gt;Hi Automate the Boring Stuff with GO series readers!&lt;/p&gt;

&lt;p&gt;I've created a proper e-book version of of Automate the Boring Stuff with GO for you to download:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://toul.gumroad.com/l/xrtry?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Automate the Boring Stuff with GO (e-book PDF)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is  especially helpful for when you don't have internet connectivity and want to follow along, so feel free to grab copy for any price you want.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Chapters 8,9,10, and 11</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Mon, 29 Jan 2024 16:11:36 +0000</pubDate>
      <link>https://dev.to/toul-nyc/chapters-8910-and-11-2793</link>
      <guid>https://dev.to/toul-nyc/chapters-8910-and-11-2793</guid>
      <description>&lt;p&gt;Hello aspiring  Gophers, it has been some time since I've updated this project.&lt;/p&gt;

&lt;p&gt;My apologies as I've gone through several major life changes, the largest of which involved moving my young family to NYC, an ongoing process that has taken much of my energy.&lt;br&gt;
The good news is the project is complete from the code side, the bad news is that it isn't from the writing side, and rather than keep you waiting, I'm going to share the code with you!&lt;/p&gt;

&lt;p&gt;So, for those of you who've made it this far Chapter 8– a Congratulations is in order "Well, done! You've made it farther than 80% of readers".&lt;/p&gt;

&lt;p&gt;To support you and the rest of your journey, I'm providing the remainder of the code and links to the projects so that you can have a look, run the code, and have it for reference in your budding career as a GoLang enthusiast.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chapter 8 - File Wrangling
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch8/projects/BackupToZip?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Backing Up Files to a Zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch8/projects/FindLargeFiles?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Find Large Files on your Computer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch8/projects/RenameDate?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Rename the Date of Files &lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Chapter 9 - Excelling with GO
&lt;/h2&gt;

&lt;p&gt;This is probably the most useful code for those in Corporate.&lt;br&gt;
Starting with Excel&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch9/projects/09_01_xlsxGo?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Census Population Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch9/projects/09_03_saveExcel?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Saving an Excel File&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch9/projects/09_04_updateProduce?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Updating cells in a sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch9/projects/09_05_multiplicationTable?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Making a Multiplication table (think matrix manipulation)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch9/projects/09_06_txtToXlsx?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;transform .txt file to Excel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch9/projects/09_07_xlsxToTxt?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Transforming Excel file  to .txt file&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Chapter 10 - PDF Hero
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch10/projects/10_01_pdfTest?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Getting Started&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch10/projects/10_02_combinePdfs?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Combining PDFs&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Chapter 11 - Web Scraping
&lt;/h2&gt;

&lt;p&gt;It is important to know that it is possible to programmatically surf the web and download data. The first code pieces show doing it using only HTTP request methods, and 'automating a browser' shows how to do so as if you were opening a browser on your computer and visiting the site. &lt;br&gt;
You'll need to do such things from time to time when Websites make it challenging to scrape data.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch11/projects/11_03_requestGet?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Basic Web Request&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch11/projects/11_04_urlSearchTerm?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Searching for Things&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch11/projects/11_05_requestSave?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Saving a web request response&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch11/projects/11_07_downloadXkcd?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Downloading content&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch11/projects/11_08_seleniumGo?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Automating a browser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch11/projects/GoogleSearch?ref=automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Searching with Google&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Wow! You've made it through all that code? Congratulations, again! &lt;/p&gt;

&lt;p&gt;You may be thinking 'Now what'. I'd recommend trying to use a little bit of what you learned at work to automate things. You may be thinking 'How will I know what or when to automate' Well a wise dev mentor once told me "If you're doing it more than 3 times a week, then maybe that's something worth automating", does anything come to mind? If so then have a look through the book for some code inspiration or even for the most likely terms to Google. &lt;br&gt;
Again, it has been a pleasure to support you on your journey so far, please do ask questions.&lt;/p&gt;

&lt;p&gt;P.S.&lt;br&gt;
If you want to get some opensource creds then maybe take a crack at writing for some of the remaining chapters, and make a Pull request on the GitHub repository. &lt;br&gt;
It can be a way to get some dev cred for your resume if you're thinking about going into the field of programming or tech in general. &lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br&gt;
Toul&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>go</category>
      <category>books</category>
    </item>
    <item>
      <title>Ch. 7 String Manipulation</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Thu, 13 Apr 2023 16:10:20 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch-7-string-manipulation-3h20</link>
      <guid>https://dev.to/toul-nyc/ch-7-string-manipulation-3h20</guid>
      <description>&lt;p&gt;In this chapter, I'm sharing the string manipulation cheatsheet in part I. to keep on hand for reference when working with strings, which you will be doing a lot of when it comes to automating day-to-day work. Then, you'll find a few useful projects to help flex your string manipulation learnings in part II.&lt;/p&gt;

&lt;p&gt;Note: Here's the &lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch7" rel="noopener noreferrer"&gt;GitHub for the Project Section&lt;/a&gt; after the Cheat Sheet&lt;/p&gt;

&lt;p&gt;I. &lt;a href="https://www.automatetheboringstuffwithgo.com/chapter-7/" rel="noopener noreferrer"&gt;String Manipulation cheatsheet&lt;/a&gt;&lt;br&gt;
Print this out, tape it by your desk, or put it in your favorite three-ring binder for school. It contains almost every string manipulation with an expression as an example for when you're working.&lt;br&gt;
String Literals &lt;/p&gt;
&lt;h2&gt;
  
  
  II. Projects
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Regex E-Mail finder from clipboard
&lt;/h3&gt;

&lt;p&gt;In this project, we'll use Regex to determine if a piece of text copied to our clipboard contains an e-mail. The pattern of finding an e-mail in a string of text is handy as you'll probably receive data where it will be useful to the group based on a common characteristic.&lt;/p&gt;

&lt;p&gt;If you're interested in building a web application with sign-up / sign-in input fields based on e-mails, this can be useful for determining whether the input is of the correct form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; There is a third-party package dependency in this project, but I trust you remember how to handle that requirement &lt;em&gt;hint&lt;/em&gt; go mod init &amp;amp; go get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
    "regexp"
    "strings"
    "github.com/atotto/clipboard"
)

func main() {
    // create email regexp
    regMail, _ := regexp.Compile(`[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}`)

    // read os buffer
    // find email regexp
    text, _ := clipboard.ReadAll()
    var mailAddr []string
    // found e-mail
    if regMail.MatchString(text) {
        mailAddr = regMail.FindAllString(text, -1)
    }

    // Print found e-mails on the terminal
    if len(mailAddr) &amp;gt; 0 {
        clipboard.WriteAll(strings.Join(mailAddr, "\n"))
        fmt.Println("Copied to clipboard:")
        fmt.Println(strings.Join(mailAddr, "\n"))
    } else {
        fmt.Println("No email addresses found.")
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Regex Password Complexity Checker
&lt;/h3&gt;

&lt;p&gt;Password complexity is an additional feature you will want to have for an application. This is because simple passwords are easier for cyber criminals to obtain/guess. &lt;/p&gt;

&lt;p&gt;Hence, it is wise to enforce a password complexity of at least 11 characters with some capital letters and numbers thrown in.  So, let's build a small program to check whether or not a given password passes the complexity requirement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
    "os"
    "regexp"

    "flag"
)

func main() {
    if len(os.Args) &amp;lt; 2 {
        fmt.Printf("Usage: %s -h\n", os.Args[0])
    } else {
        pass := flag.String("p", "", "get password")

        flag.Parse()

        regStr, _ := regexp.Compile(`([0-9a-zA-Z]){11,}`)

        if regStr.MatchString(*pass) {
            fmt.Println("Password ok")
        } else {
            fmt.Println("Bad password")
        }

        os.Exit(0)
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the program and passing in your possible password should result in either a Password OK or Bad Password response from the program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;t@m1 regexppass % go run main.go --p=23498aosethuaosthAT
Pass ok
t@m1 regexppass % go run main.go --p=2Aoeue             
Bad password
t@m1 regexppass % go run main.go --p=2AoeueEEEE
Bad password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Quiz Builder
&lt;/h2&gt;

&lt;p&gt;Now, this project is the first in our queue at automating a mundane work task--your teacher friends will love you!&lt;br&gt;
In this project, you'll build a quiz generator around the U.S. and its capitals. However, you will generally have the format of a quiz-building piece of software that can be changed to generate different sorts of quizzes. Maybe, you'll change it to do the capitals of your home country and its states.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "math/rand"
    "os"
    "strconv"
    "strings"
    "time"
)

func main() {
    capitals := map[string]string{
        "Alabama":        "Montgomery",
        "Alaska":         "Juneau",
        "Arizona":        "Phoenix",
        "Arkansas":       "Little Rock",
        "California":     "Sacramento",
        "Colorado":       "Denver",
        "Connecticut":    "Hartford",
        "Delaware":       "Dover",
        "Florida":        "Tallahassee",
        "Georgia":        "Atlanta",
        "Hawaii":         "Honolulu",
        "Idaho":          "Boise",
        "Illinois":       "Springfield",
        "Indiana":        "Indianapolis",
        "Iowa":           "Des Moines",
        "Kansas":         "Topeka",
        "Kentucky":       "Frankfort",
        "Louisiana":      "Baton Rouge",
        "Maine":          "Augusta",
        "Maryland":       "Annapolis",
        "Massachusetts":  "Boston",
        "Michigan":       "Lansing",
        "Minnesota":      "Saint Paul",
        "Mississippi":    "Jackson",
        "Missouri":       "Jefferson City",
        "Montana":        "Helena",
        "Nebraska":       "Lincoln",
        "Nevada":         "Carson City",
        "New Hampshire":  "Concord",
        "New Jersey":     "Trenton",
        "New Mexico":     "Santa Fe",
        "New York":       "Albany",
        "North Carolina": "Raleigh",
        "North Dakota":   "Bismarck",
        "Ohio":           "Columbus",
        "Oklahoma":       "Oklahoma City",
        "Oregon":         "Salem",
        "Pennsylvania":   "Harrisburg",
        "Rhode Island":   "Providence",
        "South Carolina": "Columbia",
        "South Dakota":   "Pierre",
        "Tennessee":      "Nashville",
        "Texas":          "Austin",
        "Utah":           "Salt Lake City",
        "Vermont":        "Montpelier",
        "Virginia":       "Richmond",
        "Washington":     "Olympia",
        "West Virginia":  "Charleston",
        "Wisconsin":      "Madison",
        "Wyoming":        "Cheyenne",
    }

    var states, capitalsItems []string
    for y, x := range capitals {
        capitalsItems = append(capitalsItems, x)
        states = append(states, y)
    }

    for i := 0; i &amp;lt; 35; i++ {
        // сreate the quiz text file
        str1 := "quiz_" + strconv.Itoa(i+1) + ".txt"
        quizFile, err := os.Create(str1)
        check(err)
        defer quizFile.Close()
        // create the answer key to the quiz
        str2 := "answer_key_" + strconv.Itoa(i+1) + ".txt"
        answerKeyFile, err := os.Create(str2)
        check(err)
        defer answerKeyFile.Close()

        // Create portion for students to fill out
        quizFile.WriteString("Student Number:\n\nName:\n\nDate:\n\n")
        str3 := "Quiz " + strconv.Itoa(i+1)
        quizFile.WriteString(strings.Repeat(" ", 20) + str3)
        quizFile.WriteString("\n\n")

        rand.Seed(time.Now().UnixNano())
        // mix of the States
        shuffle(states)

        // Iterate through and build the question out 
        for j := 0; j &amp;lt; 50; j++ {
            correctAnswer := capitals[states[j]]
            wrongAnswers := make([]string, len(capitalsItems))
            copy(wrongAnswers, capitalsItems)

            // shuffle wrong answers
            answNoCorrect := make([]string, len(wrongAnswers)-1)
            for l := 0; l &amp;lt; len(wrongAnswers); l++ {
                if wrongAnswers[l] == correctAnswer {
                    copy(answNoCorrect, removeAtIndex(wrongAnswers, l))
                }
            }

            // create answer options A-D
            var answerOptions []string
            for l := 0; l &amp;lt; 3; l++ {
                answerOptions = append(answerOptions, answNoCorrect[l])
            }
            answerOptions = append(answerOptions, correctAnswer)
            shuffle(answerOptions)

            // create question
            str3 := strconv.Itoa(j+1) + " What is the Capital of " + states[j] + "?" + "\n"
            quizFile.WriteString(str3)
            strAbcd := "ABCD"
            for l := 0; l &amp;lt; 4; l++ {
                strAnsw := string(strAbcd[l]) + ". " + answerOptions[l] + "\n"
                quizFile.WriteString(strAnsw)
            }
            // make quiz and save it
            quizFile.WriteString("\n")

            // make answer key and save it
            strAnswerOk := ""
            for l := 0; l &amp;lt; len(answerOptions); l++ {
                if answerOptions[l] == correctAnswer {
                    strAnswerOk += string(strAbcd[l])
                }
            }
            strCorAnsw := strconv.Itoa(j+1) + ". " + strAnswerOk + "\n"
            answerKeyFile.WriteString(strCorAnsw)
        }
    }
}

// helper functions for making quiz building easier
func check(e error) {
    if e != nil {
        panic(e)
    }
}

func shuffle(a []string) {
    for i := range a {
        j := rand.Intn(i + 1)
        a[i], a[j] = a[j], a[i]
    }
}

func removeAtIndex(source []string, index int) []string {
    lastIndex := len(source) - 1
    source[index], source[lastIndex] = source[lastIndex], source[index]
    return source[:lastIndex]
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There you have it, the foundation of all the string knowledge you'll use to work with string data in files, clipboards, or anywhere else.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>books</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ch 6. Maps</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Thu, 13 Apr 2023 16:05:22 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch-6-maps-3gi3</link>
      <guid>https://dev.to/toul-nyc/ch-6-maps-3gi3</guid>
      <description>&lt;p&gt;Like in real life, a map is a way of containing data that defines something. Think of the map of New York City. It is a piece of paper that includes data about the city's layout– depending on the map type. &lt;br&gt;
Maps are typically handy when you combine different data types because a slice will only permit one data type per-use.&lt;br&gt;
We'll briefly cover Maps so the reader can be aware of them and see when they might be useful.&lt;/p&gt;
&lt;h2&gt;
  
  
  Syntax
&lt;/h2&gt;

&lt;p&gt;A map uses the 'map' keyword and [type] followed again by 'type.'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

func main() {
  nyc := map[string]int{
      "population": 8000000,
      "size": 302,
  }
  htx := map[string]int{
    "population": 2000000,
    "size": 665,
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It says a map made of key-pair values of type string and int.&lt;br&gt;
You can have any combination of types with maps, which is when you should consider using them over a slice.&lt;/p&gt;
&lt;h2&gt;
  
  
  Use case
&lt;/h2&gt;

&lt;p&gt;Although the data is small above it is enough to let us access quick facts about each city with a fast lookup, with syntax similar to a slice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"
func main() {
  nyc := map[string]int{
      "population": 8000000,
      "size": 302,
  }
  htx := map[string]int{
    "population": 2000000,
    "size": 665,
  }
  fmt.Println(htx["population"], nyc["population"])
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The curious reader should take a look at Go Maps in Action by the GO dev team to get a better sense of when to use 'maps'. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is enough to know a map and how it generally works. Now, let's move on to part II of automating the boring stuff with go, which contains much more fun practical examples.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>books</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ch. 5 Slices</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Thu, 13 Apr 2023 16:02:46 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch-5-slices-2fck</link>
      <guid>https://dev.to/toul-nyc/ch-5-slices-2fck</guid>
      <description>&lt;p&gt;Slices in Golang are the same as dynamic arrays. An array is the first data structure you'll probably learn about in any book related to learning a programming language. Slices can contain any data type, including a slice itself, making arranging data into hierarchical structures simpler.&lt;br&gt;
In this chapter, we'll go over the basics of Slices, and I'll teach you about some of the most useful methods available to slices. &lt;/p&gt;
&lt;h2&gt;
  
  
  The Slice Data Type
&lt;/h2&gt;

&lt;p&gt;The slice type has an upper and lower bound separated by a colon but is not inclusive, meaning that the upper bound value isn't used.&lt;br&gt;
For example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    evens := [5]int{2, 4, 6, 8, 10 }
    var s []int = evens[1:4]
    fmt.Println(s)

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will output &lt;br&gt;
"4 6 8 "&lt;/p&gt;
&lt;h2&gt;
  
  
  Accessing values in a slice with Indexes
&lt;/h2&gt;

&lt;p&gt;Like many other languages in GO, getting a single value from a slice is possible. Let's say instead of using evens[1:4], it had read evens[0]  will only output "2". &lt;br&gt;
Slice of Slices&lt;br&gt;
Slices may contain any type, including other slices, which can be considered a grid when used. A familiar example for those not into math is Tic-tac-toe rather than the x,y coordinate plane.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
    "strings"
)

func main() {
    // Create a tic-tac-toe board.
    board := [][]string{
        []string{"_", "_", "_"},
        []string{"_", "_", "_"},
        []string{"_", "_", "_"},
    }

    // The players take turns.
    board[0][0] = "X"
    board[2][2] = "O"
    board[1][2] = "X"
    board[1][0] = "O"
    board[0][2] = "X"

    for i := 0; i &amp;lt; len(board); i++ {
        fmt.Printf("%s\n", strings.Join(board[i], " "))
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which will output,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X _ X
O _ X
_ _ O
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using empty slices
&lt;/h2&gt;

&lt;p&gt;An empty-sized slice is helpful when you don't know how many elements will be in it, but you do plan on using it. So you'd declare it like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    a := []int{}
    fmt.Println(a)

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which will output '[],' showing that it's an empty slice waiting to be filled.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Appending to a Slice
&lt;/h2&gt;

&lt;p&gt;When working with slices, it is often necessary to add new elements to the slice, and the appropriate way of doing so in go is to use the 'append' method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    var s []int
    printSlice(s)

    // append works on nil slices.
    s = append(s, 0)
    printSlice(s)

    // The slice grows as needed.
    s = append(s, 1)
    printSlice(s)

    // We can add more than one element at a time.
    s = append(s, 2, 3, 4)
    printSlice(s)
}

func printSlice(s []int) {
    fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Getting a Slice's length with len() func.
&lt;/h2&gt;

&lt;p&gt;Similarly, to add elements to a slice, it is often essential to know how many features are inside a slice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    s := []int{2, 3, 5, 7, 11, 13}
    fmt.Println(len(s))


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Changing Values in a Slice with Indexes
&lt;/h2&gt;

&lt;p&gt;Sometimes, you'll also want to update a specific value in the Slice without altering others.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    s := []int{2, 3, 5, 7, 11, 13}
    s[1] = 234234
    fmt.Println(s)


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which will output&lt;code&gt;[2 234234 5 7 11 13]&lt;/code&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Using Slices
&lt;/h2&gt;

&lt;p&gt;Okay, now that the basics of slices are down, let's see how and why we'd probably use a slice to automate our mundane tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  For loops
&lt;/h3&gt;

&lt;p&gt;Loops and Slices go together like milk and cookies, and GO a unique range syntax for going through a slice, element by element and value by value.&lt;/p&gt;

&lt;p&gt;Suppose you had data about the prices of paper you were selling and needed to update them to account for inflation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"



func main() {
    paperPrices := []float32{1.00, 2.00, 4.00, 8.00, 16.00, 32.00, 64.00, 128.00}
    inflatedPaperPrices := make([]float32, len(paperPrices))
    for i, v := range paperPrices {
        inflatedPaperPrices[i] = (v * 0.08) + v
    }
    fmt.Println(inflatedPaperPrices)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the 'make' keyword was used when declaring the inflatedPaperPrices slice. The make statement is used in GO to create variables with predetermined lengths and types. It is often best practice and, in this case, must be done. &lt;/p&gt;

&lt;p&gt;Let's break it down, starting with 'i' and 'v'– these are the for loop variables that only exist within the for loop and may be named anything, but typically 'i' and 'v' are used by tradition. Because 'i' can be thought of as 'index' and 'v' as 'value'.&lt;/p&gt;

&lt;p&gt;So, range lets us iterate (go through) a slice and access either the value or index or both.  The range syntax is a shortcut to write a for loop in GO. The code above could be written in a longer form like so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"



func main() {
    paperPrices := []float32{1.00, 2.00, 4.00, 8.00, 16.00, 32.00, 64.00, 128.00}
    inflatedPaperPrices := make([]float32, len(paperPrices))
    for i:=0; i &amp;lt; len(paperPrices); i++ {
        inflatedPaperPrices[i] = (paperPrices[i] * 0.08) + paperPrices[i]
    }
    fmt.Println(inflatedPaperPrices)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Now that the basics of slices have been covered, let's move on.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>books</category>
      <category>programming</category>
    </item>
    <item>
      <title>Linode + DEV Hackathon</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Thu, 09 Feb 2023 18:52:33 +0000</pubDate>
      <link>https://dev.to/toul-nyc/linode-dev-hackathon-c16</link>
      <guid>https://dev.to/toul-nyc/linode-dev-hackathon-c16</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Gitty Up &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjycwvpzccxqbjawy4m0o.png" alt="Gitty Up Sec." width="100" height="100"&gt;
&lt;/h3&gt;

&lt;p&gt;It’s a web app where a user can create an account and add an admin GitHub.com token so that they can run their GitHub org against security best practices;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning" rel="noopener noreferrer"&gt;secret scanning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning" rel="noopener noreferrer"&gt;static code analysis&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/code-security/dependabot/dependabot-alerts/about-dependabot-alerts" rel="noopener noreferrer"&gt;dependency scanning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches" rel="noopener noreferrer"&gt;branch protections&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For each repo present in the Org. with a single report generated.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; It currently does not support privately self-hosted GitHub Enterprise Integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category Submission:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;SaaS&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.gittyupsec.com" rel="noopener noreferrer"&gt;GittyUpSec.com&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvnshyk35w05n5ozwnyvh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvnshyk35w05n5ozwnyvh.gif" alt="GittyUpSec Demo" width="1200" height="675"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;p&gt;Used for analyzing an organization’s repos at scale to show which could use hardening for security best practices with GitHub.com's available features &lt;/p&gt;

&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cowboyhat-io/gittyupsec.com" rel="noopener noreferrer"&gt;GittyUp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/cowboyhat-io/gittyupsec.com/blob/main/LICENSE" rel="noopener noreferrer"&gt;MIT&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;(What made you decide to build this particular app? What inspired you?)&lt;/p&gt;

&lt;p&gt;I recently obtained my CISSP and as part of retaining it continuing professional education (CPE) credits are required. &lt;/p&gt;

&lt;p&gt;So, I watched an ISC^2 presentation over the troubles of securing GitHub Repos, which counts as 1 CPE credit. &lt;/p&gt;

&lt;p&gt;I was shocked at how many Fortune 500 companies were being breached due to misconfigured GitHub repos.&lt;/p&gt;

&lt;p&gt;Hence, I thought it could be a fun Friday night project to build a simple web app that could be used in the cloud or ran locally to check an Orgs security posture for GitHub.   &lt;/p&gt;

&lt;p&gt;Hence, GittyUp is built in GO which makes it easy to share across operating systems. &lt;/p&gt;

&lt;p&gt;Later, I plan to create a CLI version of it as well as a Docker containerized version to make it even easier to use on one’s local computer. &lt;/p&gt;

&lt;p&gt;I really hope it can help with stopping the data breaches caused by poor GitHub Repository Configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I built it
&lt;/h3&gt;

&lt;p&gt;(How did you utilize Linode? Did you learn something new along the way? Pick up a new skill?)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I learned how to use Linode servers for running a web app which was tricky as it required installing it as a service on the Linode server. However, using Docker could make it easier as Linode has a Docker based server. But I kept it simple since it was a brief hackathon. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I also learned how to map a &lt;a href="https://www.namecheap.com/" rel="noopener noreferrer"&gt;namecheap.com&lt;/a&gt; domain to the Linode server IP which was really easy to do in the Linode Console. It was just a click of the button and editing a few records within the NameCheap control panel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I also learned how to use Linode Database Clusters which were also easy to set up in the console and upon set up provided all the credentials in an easy to view manner for connecting to the database. However, I opted to install the DB locally on the Linode server to reduce costs because I didn't want to go over the credit nor use a virtual DB/CPU.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Additional Resources/Info
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://merelycurious.me/post/connecting-namecheap-domain-to-linode" rel="noopener noreferrer"&gt;How to connect NameCheap domain to Linode&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linode.com/products/postgresql/" rel="noopener noreferrer"&gt;PostGres Database Clusters&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linode.com/docs/products/platform/get-started/#create-your-first-compute-instance" rel="noopener noreferrer"&gt;How to Sign-up for Linode and Create a Server&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>announcement</category>
      <category>devto</category>
      <category>web3</category>
    </item>
    <item>
      <title>How I obtained my CISSP</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Wed, 25 Jan 2023 18:15:48 +0000</pubDate>
      <link>https://dev.to/toul-nyc/how-i-obtained-my-cissp-hhe</link>
      <guid>https://dev.to/toul-nyc/how-i-obtained-my-cissp-hhe</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;The Certified Information Systems Security Professional or &lt;strong&gt;CISSP&lt;/strong&gt; is known for its rigorous exam and challenging requirement of needing at least 5 years of experience working in security-related roles.&lt;/p&gt;

&lt;p&gt;I'm happy to say I was able to pass on the &lt;a href="https://www.credly.com/badges/7b392b79-9aa6-4169-bb71-7f4d2d17909e/linked_in?t=rnxf6e" rel="noopener noreferrer"&gt;first attempt&lt;/a&gt; and would like to share my experience and study path with others interested in the CISSP.  &lt;/p&gt;

&lt;h2&gt;
  
  
  I. Career Background
&lt;/h2&gt;

&lt;p&gt;DevSecOps engineer for 4 1/2 years building security features for a platform in AWS cloud with Python, Go, and Kubernetes which obtained the  ISO 27001 &amp;amp; ISO 27002 type I and Type II. During that time, I also received the &lt;a href="https://www.credly.com/badges/b0ce04c9-cdf7-4e00-9520-830a1c1b8385/linked_in" rel="noopener noreferrer"&gt;AWS security specialty certification&lt;/a&gt;. Then moved to a whole security infrastructure security analyst job for about 5 months before attempting the CISSP Exam. &lt;/p&gt;

&lt;p&gt;I felt that being in a DevSecOps role building a platform was advantageous since most of my day-to-day work revolved around the &lt;a href="https://www.isc2.org/Certifications/cissp/Certification-Exam-Outline" rel="noopener noreferrer"&gt;8 tested&lt;/a&gt; domains of the CISSP;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Security and Risk Management&lt;/li&gt;
&lt;li&gt;Asset Security&lt;/li&gt;
&lt;li&gt;Security Architecture and Engineering&lt;/li&gt;
&lt;li&gt;Communication and Network Security&lt;/li&gt;
&lt;li&gt;Identity and Access Management (IAM)&lt;/li&gt;
&lt;li&gt;Security Assessment and Testing&lt;/li&gt;
&lt;li&gt;Security Operations&lt;/li&gt;
&lt;li&gt;Software Development Security&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  II. Study Plan
&lt;/h2&gt;

&lt;h3&gt;
  
  
  II.a Get a Smaller Cert First
&lt;/h3&gt;

&lt;p&gt;Obtaining a cert or two before going after the CISSP will be helpful because it will aid in building/refreshing study skills and building confidence. So, I first went after the AWS Security Specialty certification and recommend readers to do the same by selecting one of interest for themself. &lt;/p&gt;

&lt;h3&gt;
  
  
  II.b Books, Courses, and Bootcamp
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/CISSP-All-One-Guide-Ninth/dp/1260467376/ref=pd_lpo_1?pd_rd_w=anVOd&amp;amp;content-id=amzn1.sym.116f529c-aa4d-4763-b2b6-4d614ec7dc00&amp;amp;pf_rd_p=116f529c-aa4d-4763-b2b6-4d614ec7dc00&amp;amp;pf_rd_r=VBGTEQV2PKWXDC3CMF72&amp;amp;pd_rd_wg=LAVUr&amp;amp;pd_rd_r=88361f35-3307-4445-8d39-785e239734eb&amp;amp;pd_rd_i=1260467376&amp;amp;psc=1" rel="noopener noreferrer"&gt;All in One cover to cover&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I read it on  my kindle over a month by aiming for 1-3% a day before bed, spacing it out helped me since the material is dry and is what I would recommend for all the books provided. But some folks are able to read them all in a month. In the end go at the speed that works for you and at which you can retain information without falling asleep. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://thorteaches.com" rel="noopener noreferrer"&gt;Thors course&lt;/a&gt; and Boson questions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I didn't use Thors Course at all— the material felt redundant with info found in All in One and Official Study Guide. Also, I wouldn't say I liked that I had to set the play speed for each video manually to x2, so it interrupted me while working and listening. However, it is a well done video course for those who prefer videos. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Certified-Information-Security-Professional-Official/dp/1119790026/ref=pd_lpo_2?pd_rd_w=rHBsr&amp;amp;content-id=amzn1.sym.116f529c-aa4d-4763-b2b6-4d614ec7dc00&amp;amp;pf_rd_p=116f529c-aa4d-4763-b2b6-4d614ec7dc00&amp;amp;pf_rd_r=JKNZ22KTX8GF95DY18Q7&amp;amp;pd_rd_wg=Lb1ku&amp;amp;pd_rd_r=1a8e8972-d027-49f7-b834-8cf6256f9e74&amp;amp;pd_rd_i=1119790026&amp;amp;psc=1" rel="noopener noreferrer"&gt;Official Study Guide and  Official Study Guide  test questions bundle&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I went through every question at least once until I got 90% of them right. For those that might not be aware within Official Study Guide books there are registration codes for Wiley's digital practice exams which I strongly recommend.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://trainingcamp.com/training/cissp-certification-bootcamp/?gclid=EAIaIQobChMIz-jRrqPj_AIVRTiGCh2axAG-EAAYASAAEgL0DvD_BwE" rel="noopener noreferrer"&gt;Training Camp week Bootcamp&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I did the BootCamp because the company offered to pay with no strings attached, so I figured sure why not. It was a grueling 5 day 12 hour a day experience with great books provided. Yet, I didn't read the books that came with that course felt redundant since I had already read the others.&lt;/p&gt;

&lt;p&gt;However, I took lots of notes from the in-class session on the digital pad (my style of learning, which was especially helpful for the cryptography sections.&lt;/p&gt;

&lt;p&gt;I focused on the "test-taker mentality" that the course instructor taught. Like how to select the best answers for the CISSP exam and how to think like a manager (I think this was most beneficial but can be found online pretty easily).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pocket Prep phone app &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I tried it but found it to be lesser than the already paid-for OSG tests and questions.&lt;/p&gt;

&lt;p&gt;I didn't like the paywall since I had already paid for other resources and frankly the official resources are more than enough despite what others might say.&lt;/p&gt;

&lt;p&gt;Doing, all the above took around 6 months to a year to accomplish. I prefer to space things out but others might prefer prepping in a shorter amount of time. &lt;/p&gt;

&lt;p&gt;What is most important is finding a routine and sticking with it which for me was typically reading before bed and doing at least one practice exam a day of 120 Questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  III. Days leading up to test
&lt;/h2&gt;

&lt;p&gt;I kept doing OSG practice tests and &lt;br&gt;
listened to YouTube videos by &lt;a href="https://www.youtube.com/watch?v=HWg2geVJuvs" rel="noopener noreferrer"&gt;Larry Greenblatt&lt;/a&gt; and &lt;a href="https://www.youtube.com/watch?v=v2Y6Zog8h2A" rel="noopener noreferrer"&gt;Kerry&lt;/a&gt; for thinking like a manager for the exam&lt;/p&gt;

&lt;h2&gt;
  
  
  IV. Day of test
&lt;/h2&gt;

&lt;p&gt;I didn't sleep the night before from nerves, so I arrived with only 4 hours of sleep and went through the exam in 175 Qs at around 143 mins.&lt;/p&gt;

&lt;p&gt;I took a break when I got frustrated with the vagueness of some questions and just started to click out of annoyance.&lt;/p&gt;

&lt;h3&gt;
  
  
  IV.a Test taking strategy
&lt;/h3&gt;

&lt;p&gt;I focused on picking the best answer and trusting my gut.&lt;br&gt;
It would be mentally exhausting to pick the 'right' answer each time versus the other choice, so I trusted my gut after reading the question 3 times.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read each answer choice once&lt;/li&gt;
&lt;li&gt;Start with the Last answer choice, then read up&lt;/li&gt;
&lt;li&gt;Pick the Cheapest option if stuck between choices&lt;/li&gt;
&lt;li&gt;Pick the thinking option if stuck between 2 choices&lt;/li&gt;
&lt;li&gt;Test Qs review&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The technical questions were decently similar to tech questions from OSG in terms of &lt;strong&gt;format&lt;/strong&gt; 1-3 sentences&lt;br&gt;
Overall, though, the questions weren't anything like the study material as anyone who's taken it will tell you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope my shared plan helps you if you're going after the &lt;strong&gt;CISSP&lt;/strong&gt;. I'm happy to answer any other questions as well!&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>ai</category>
      <category>documentation</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Ch. 4 Functions</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Fri, 06 Jan 2023 22:09:31 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch-4-functions-1b5n</link>
      <guid>https://dev.to/toul-nyc/ch-4-functions-1b5n</guid>
      <description>&lt;p&gt;You've already seen &lt;strong&gt;func&lt;/strong&gt;'s multiple times so far, but let's take this chapter to understand them better and when to use them when automating work.&lt;/p&gt;

&lt;p&gt;Functions are reusable work units for a program to use, and they save programmers from repeating themselves. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You might hear this paradigm as &lt;strong&gt;D.R.Y.&lt;/strong&gt; when speaking with other coders, which stands for "Don't repeat yourself".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Functions are like small programs within your program. And GO, in particular, must always have the &lt;strong&gt;func main() {}&lt;/strong&gt; within the &lt;code&gt;main.go&lt;/code&gt; file. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;main&lt;/strong&gt; func is to tell the compiler (go build) that this is where the code starts. Remember, computers execute code line by line, so it helps to tell them which line to begin with.&lt;/p&gt;

&lt;h2&gt;
  
  
  I.Parts of a function
&lt;/h2&gt;

&lt;p&gt;Let's start with a basic function and try to understand what each part of it is called and what it is responsible for.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 1
package main 

func NameIs(name string){ // (1)
    fmt.Printf("Your name is: %s", name)
}

func main() {
    NameIs("Gopher") // (2)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(1)&lt;/strong&gt; The characters succeeding the 'func' keyword give the name to the 'func'. &lt;/p&gt;

&lt;p&gt;In this example, it is correct to say the function's name is, well, &lt;strong&gt;NameIs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And the characters within the parentheses 'name string' is the accepted argument(s). &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; There can be more than one argument that a function can to do work on. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;(2)&lt;/strong&gt; It Is known as the 'function call,' or the function is being 'called/invoked'. That is a fancy way of saying, "the function is being used". &lt;/p&gt;

&lt;h2&gt;
  
  
  I.a When to get func-e (funky)?
&lt;/h2&gt;

&lt;p&gt;Frequently whenever you're writing code, you might get it working-- and that is fine and a noble goal on the first pass. However, on the second pass (immediately, once it is working), it's time to &lt;strong&gt;refactor&lt;/strong&gt;, which means doing things like reducing repetition by using functions. &lt;/p&gt;

&lt;h3&gt;
  
  
  I.b Example
&lt;/h3&gt;

&lt;p&gt;Suppose we say hello to a bunch of readers without using a function. Here's how repetitive it will look.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 2
package main 

func main() {
    fmt.Printf("Hello %s", "Gopher")
        fmt.Printf("Hello %s", "Gopher2")
    fmt.Printf("Hello %s", "Gopher3")
        fmt.Printf("Hello %s", "Gopher4")
    fmt.Printf("Hello %s", "Gopher5")
        fmt.Printf("Hello %s", "Gopher6")
    fmt.Printf("Hello %s", "Gopher7")
        fmt.Printf("Hello %s", "Gopher8")
    fmt.Printf("Hello %s", "Gopher9")
        fmt.Printf("Hello %s", "Gopher10")

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's do a &lt;strong&gt;refactor&lt;/strong&gt; to make it a bit &lt;strong&gt;DRY&lt;/strong&gt;er.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 3
package main

import "fmt"

func greetReaders(n []string) {
    for _, name := range n {
        fmt.Printf("\nHello %s", name)
    }
}

func main() {
    rdrs := []string{
        "Gopher",
        "Gohper2",
        "Gopher3",
        "Gohper4",
        "Gopher5",
        "Gohper6",
        "Gopher7",
        "Gohper8",
        "Gopher9",
        "Gohper10",
    }
    greetReaders(rdrs)

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  II. Multiple different kinds of arguments
&lt;/h2&gt;

&lt;p&gt;Suppose we wanted to print a reader's name and age. Then we'll need string type data and number type data. In GO the arguments can be a mix of different types like string and int, not just a mono-type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 5 Multiple Argument types
package main

import "fmt"

func HappyBirthday(n string, age int) {
    fmt.Printf("Happy birthday %s, You're turning %d", n, age)
}

func main() {
    HappyBirthday("Go", 20)

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  III. &lt;code&gt;return&lt;/code&gt; values
&lt;/h2&gt;

&lt;p&gt;So far, the functions defined haven't used the 'return' keyword, which means they're only doing something with the data passed in but not giving it back.&lt;/p&gt;

&lt;p&gt;Let's go back to our even/odd examples and sort integer arrays into odd and even.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 4 Returning values
import "fmt"

func EvenOdd(n []int) ([]int, []int) {  // (1)
    var odd, even []int
    for _, num := range n {
        if num%2 == 0 {
            even = append(even, num)
        }
        if num%2 == 1 {
            odd = append(odd, num)
        }

    }
    return odd, even // (2)
}

func main() {
    num := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
    odd, even := EvenOdd(num) // (3) 
    fmt.Println("Odd: ", odd)
    fmt.Println("Even: ", even)

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(2)&lt;/strong&gt; The 'return' keywords say at the end of this function call, give the &lt;em&gt;value&lt;/em&gt; to the caller. The big idea here is that the 'value' returned can be 'assigned' to variables, which can then be passed further along in the program. &lt;/p&gt;

&lt;p&gt;Notice, in GO, that you can return multiple values and assign them at once in &lt;strong&gt;(3)&lt;/strong&gt;. However, this can be tricky, so it's not recommended as you're starting out. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(1)&lt;/strong&gt; The astute reader probably caught the additional parentheses following the accepted arguments; ([]int, []int). The second set of parentheses is required when returning multiple values. It lets the reader know the &lt;code&gt;types&lt;/code&gt; expected after a successful invocation of the func. &lt;/p&gt;

&lt;p&gt;Similarly, you can return multiple different data types as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 5 Returning multiple values 
package main

import "fmt"

func diffVals(n string, age int) (string, int) { // (1)
    return n, age
}

func main() {
    name, age := diffVals("Gopher", 20)
    fmt.Printf("name: %s, age: %d", name, age)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;(1)&lt;/strong&gt; Shows that a string type and int type will be returned at the end of a successful function call.&lt;/p&gt;

&lt;p&gt;As you write code to solve problems, your programs will be more extensive than 20 lines. &lt;/p&gt;

&lt;p&gt;Having functions that return data makes it simpler to keep track of what's going on in your program for you and other readers. &lt;/p&gt;

&lt;h2&gt;
  
  
  IV. Local variables and Global Variables
&lt;/h2&gt;

&lt;p&gt;In all our code so far, we've mainly been using &lt;code&gt;local&lt;/code&gt; variables, and now it is time to discuss what that means and what &lt;code&gt;global&lt;/code&gt; means. &lt;/p&gt;

&lt;p&gt;The distinction is that a &lt;code&gt;local&lt;/code&gt; variable and its value are only accessible within the block of code in which it exists. Whereas a &lt;code&gt;global&lt;/code&gt; variable may be accessed outside of the code block and across all of your program files. In general, &lt;code&gt;global&lt;/code&gt; variables are frowned upon in GO programs, but in other languages, they're not so frowned upon. &lt;/p&gt;

&lt;p&gt;Let's see an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 6 Globals are tricky
package main

import "fmt"

// global variables
var Author = "Gopher"
var Age = 20

func LocalAuthor(name string, age int) {
    Author = name
    Age = age
    fmt.Printf("\nAuthor: %s, \nAge: %d", name, age)
}

func main() {
    LocalAuthor("Gopher2", 40)
    fmt.Printf("\nAuthor: %s, \nAge: %d", Author, Age)

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above, the &lt;code&gt;global&lt;/code&gt; variables have their values reassigned within the function call of &lt;code&gt;LocalAuthor&lt;/code&gt;, which might cause problems in other parts of the program if the expected values were "Gopher" and &lt;code&gt;20&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To get the expected behavior, define local variables within the function 'n' and 'a' for name and age, respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 7 Locals are preferred
package main

import "fmt"

// global variables
var Author = "Gopher"
var Age = 20

func LocalAuthor(name string, age int) {
    n := name // don't reference the global variables
    a := age
    fmt.Printf("\nAuthor: %s, \nAge: %d", n, a)
}

func main() {
    LocalAuthor("Gopher2", 40)
    fmt.Printf("\nAuthor: %s, \nAge: %d", Author, Age)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  V. Error handling
&lt;/h2&gt;

&lt;p&gt;One of the few areas where GO receives complaints is with error handling in that it is often verbose and redundant. However, the idea is that errors should be explicitly handled and error situations described. &lt;/p&gt;

&lt;p&gt;Let's set up a function that will return an 'error' type if the received argument is 'empty'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
package main

import (
    "errors"
    "fmt"
    "log"
)

// Hello returns a greeting for the named person.
func Hello(name string) (string, error) {
      // If a name isn't received then there's no one to greet and it should return an error
    if name == "" {
        return "", errors.New("Err: empty name")
    }
        // otherwise great the person and return a nil for error
    message := fmt.Sprintf("Hi, %v. Welcome!", name)
    return message, nil
}

func main() {
    // Set properties of the predefined Logger, including
    // the log entry prefix and a flag to disable printing
    // the time, source file, and line number.
    log.SetPrefix("greetings: ")
    log.SetFlags(0)

    // Request a greeting message.
    message, err := Hello("")
    // If an error was returned, print it to the console and
    // exit the program.
    if err != nil {
        log.Fatal(err)
    }

    // If no error was returned, print the returned message
    // to the console.
    fmt.Println(message)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Error handling is a must if you're going to be building functions that you intend to share with the world or a team or with your future self. &lt;/p&gt;

&lt;p&gt;However, just starting out it might not be as necessary when you're hacking something together. &lt;/p&gt;

&lt;p&gt;But, now you are aware of the general style if you should be happen to digging around through some package documentation. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Functions are an essential paradigm in any program language-- in fact there's languages that are purely &lt;strong&gt;functional&lt;/strong&gt;. The key takeaways are that as a reader of a function you'll probably be most interested in what arguments it takes and what values it returns, not so much the code is within the function.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>go</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ch. 3 Flow Control</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Tue, 29 Nov 2022 19:47:05 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch-3-flow-control-196</link>
      <guid>https://dev.to/toul-nyc/ch-3-flow-control-196</guid>
      <description>&lt;p&gt;In the previous chapter, we covered the basics of GO data types and, in a few examples, used flow control to print messages. &lt;/p&gt;

&lt;p&gt;In this chapter, we'll use what we learned about comparison operators and boolean values to learn more about flow control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Elements of Flow control
&lt;/h2&gt;

&lt;p&gt;Programs are like water in a river because they tend to flow in one direction. And like water in a river, parts of it can go off into separate outlets based upon the river's conditions, such as a boulder in the stream or a dam.&lt;/p&gt;

&lt;p&gt;However, unlike water in a river, it's much easier to divert the flow of a program. &lt;/p&gt;

&lt;p&gt;To do so, we use conditions to evaluate a variable's value or the output of a function and execute a different code block. &lt;/p&gt;

&lt;p&gt;Let's use an example with comments to see. &lt;/p&gt;

&lt;p&gt;We are using the familiar 'if' from the previous chapter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Ex. 1 Tell me if a number is even or odd
package main

import (
    "fmt"
    "math/rand"
)

func main() {
    // use the rand library to generate a random integer.
    n := rand.Intn(100)
    // 'if' condition
    if n%2 == 0 {
        // code block that's executed if the condition is true
        fmt.Printf("Number is even: %d", n)
    }
    // code block that's executed if it isn't true
    fmt.Printf("Number is odd: %d", n)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this program, we're checking whether a &lt;em&gt;'random'&lt;/em&gt; integer number is even or not via the &lt;em&gt;modulo operator&lt;/em&gt; &lt;code&gt;%&lt;/code&gt;, which is a fancy way of saying 'dividing with remainders'. &lt;/p&gt;

&lt;p&gt;If you recall, an &lt;em&gt;even&lt;/em&gt; number can be divided in two without any remainders, whereas an &lt;em&gt;odd&lt;/em&gt; number cannot. &lt;/p&gt;

&lt;p&gt;Don't worry about the math. Just note that the logic of the program changes based on the condition, which is the &lt;em&gt;'random'&lt;/em&gt; value of the &lt;strong&gt;n&lt;/strong&gt;  variable. &lt;/p&gt;

&lt;p&gt;Now, let's introduce the rest of the gang for flow control. &lt;/p&gt;

&lt;h2&gt;
  
  
  Flow Control Statements
&lt;/h2&gt;

&lt;h2&gt;
  
  
  'if' statements
&lt;/h2&gt;

&lt;p&gt;These are the most used control statements, and you'll almost always use them when adding 'logic' to your programs. &lt;/p&gt;

&lt;p&gt;The general pattern is that your program has a chunk of code that will only be executed if the condition is considered 'true' or 'false.'&lt;/p&gt;

&lt;h2&gt;
  
  
  'else' statements
&lt;/h2&gt;

&lt;p&gt;Technically, in the previous 'if' example, we could've had an 'else' statement to print the 'number is odd:' part, but we kept it cleaner by leaving it out, which is a preference amongst programmers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 2 else
package main

import (
    "fmt"
    "math/rand"
)

func main() {
    // use the rand library to generate a random integer.
    n := rand.Intn(100)
    // 'if' condition
    if n%2 == 0 {
        // code block that's executed if the condition is true
        fmt.Printf("Number is even: %d", n)
    } else {
        // code block that's executed if it isn't true
        fmt.Printf("Number is odd: %d", n)
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Else statements say 'hey, if this piece of logic turns out to be false or something else, then do this.' &lt;/p&gt;

&lt;p&gt;Typically, 'else' statements aren't preferred because they aren't explicit and will catch only when the condition is false. &lt;/p&gt;

&lt;p&gt;Let's introduce the else's, cousin.&lt;/p&gt;

&lt;h2&gt;
  
  
  else if
&lt;/h2&gt;

&lt;p&gt;Here, we can communicate what we want to happen 'if' the first condition evaluates to 'false' and explicitly define what should happen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 3 else if 
package main

import (
    "fmt"
    "math/rand"
)

func main() {
    // use the rand library to generate a random integer.
    n := rand.Intn(100)
    // 'if' condition
    if n%2 == 0 {
        // code block that's executed if the condition is true
        fmt.Printf("Number is even: %d", n)
    } else if n%2 == 1 {
        // code block that's executed if it isn't true
        fmt.Printf("Number is odd: %d", n)
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  switch
&lt;/h2&gt;

&lt;p&gt;The 'switch' control flow works much the same as using 'if' 'else' or 'else if' but presents differently in the form of 'cases'. A 'case' is the same as a condition and may be preferred by those with a mathematical background. Either style works; use whichever makes sense to you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 4 switch
package main

import (
    "fmt"
    "time"
)

func main() {

    // You can use commas to separate multiple expressions
    // in the same `case` statement. We use the optional
    // `default` case in this example as well.
    switch time.Now().Weekday() {
    case time.Saturday, time.Sunday:
        fmt.Println("It's the weekend")
    default:
        fmt.Println("It's a weekday")
    }

    // `switch` without an expression is an alternate way
    // to express if/else logic. Here we also show how the
    // `case` expressions can be non-constants.
    t := time.Now()
    switch {
    case t.Hour() &amp;lt; 12:
        fmt.Println("It's before noon")
    default:
        fmt.Println("It's after noon")
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above, we say 'switch' based upon the following 'case' and pass in some data. The same again can be accomplished by using 'if' and 'else if'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex. 5 convert switch to if else
package main

import (
    "fmt"
    "time"
)

func main() {
    if t.Hour() &amp;lt; 12 {
        fmt.Println("before noon")
    } else if t.Hour() &amp;gt; 12 {
        fmt.Println("it's after noon")
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In general, I prefer using 'switch' and including the optional 'default' case because I find it easier to test my 'cases' and to convey to others what I'm trying to do with my code. &lt;/p&gt;

&lt;h2&gt;
  
  
  Loops
&lt;/h2&gt;

&lt;p&gt;Now that we have some logic to control a program's flow, it's time to introduce 'loops'. A loop is a way we tell computers to "do work for x amount of times". Let's combine it with loops to make a more intelligent program.&lt;/p&gt;

&lt;p&gt;A 'for' loop also uses a condition to do its work, but it works 'until' that condition is satisfied. So, for example, the saying 'a thousand thanks' we'll have a program that will say 'thank you' a thousand times based upon a reader's name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex 5. If you're a reader, then a thousand thanks
package main

import "fmt"

func main() {
   fmt.Println("Enter your name")
   var n string
   fmt.Scan(&amp;amp;n)
   switch {
   case n == "Toul":
         fmt.Printf("The author is %s ",  n)
   default:
     // a thousand thanks if you're not the author
      for i := 0; i &amp;lt; 1000; i++ {
         fmt.Printf("\ni: %d Thank you %s for reading", i, n)
      }
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above the 'for' loop syntax is &lt;em&gt;for&lt;/em&gt; &lt;strong&gt;initial condition&lt;/strong&gt;; &lt;em&gt;compare&lt;/em&gt; ;&lt;strong&gt;if not met then do another&lt;/strong&gt; { // work to be done }&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In most programming languages, it is common to start at '0', so keep this in mind when working with arrays, slices, and initial loop conditions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Okay, let's have some fun by building a few small games to show your friends and family at the winter holiday parties.&lt;/p&gt;

&lt;p&gt;Don't worry if some syntax is unfamiliar. We want to focus on building muscle memory and familiarity with GO. So, try your best to copy the code and get in running. If you have any troubles at all the &lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch3" rel="noopener noreferrer"&gt;source code is available&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Guess the Number
&lt;/h2&gt;

&lt;p&gt;In this first game we'll have the computer pick a random number and then try to guess it by inputting guesses, but the catch is we only get '3' attempts!&lt;/p&gt;

&lt;p&gt;But, we'll give the user clues to increase the chances of winning within 3.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
   "fmt"
   "math/rand"
   "time"
)

func main() {
   fmt.Println("Game: Guess a number between 0 and 10")
   fmt.Println("You have three(3) tries ")

   source := rand.NewSource(time.Now().UnixNano())
   randomizer := rand.New(source)
   secretNumber := randomizer.Intn(10)

   var guess int

   for try := 1; try &amp;lt;= 3; try++ {

      fmt.Printf("Attempt: %d\n", try)
      fmt.Println("Enter your number: ")
      fmt.Scan(&amp;amp;guess)

      switch {
      case guess &amp;lt; secretNumber:
         fmt.Printf("Sorry, wrong guess ; number is too small\n ")
      case guess &amp;gt; secretNumber:
         fmt.Printf("Sorry, wrong guess ; number is too large\n ")
      case guess == secretNumber:
         fmt.Printf("You win!")
      case try == 3:
         fmt.Printf("Game over!!\n ")
         fmt.Printf("The correct number is %d\n", secretNumber)
      default:
         fmt.Println("I don't recognize that input. Try a number like '1'")
      }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced: Rock, Paper, Scissors
&lt;/h2&gt;

&lt;p&gt;Now, for a more fun and more advanced example to wet your programmer appetite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
   "fmt"
   "math/rand"
   "strings"
   "time"
)

func getInput() string {
   // get input and use strings package to convert to lowercase b/c this is a good practice when working with inputs 
   // in general
   fmt.Print("Pick [r]ock, [p]aper, or [s]cissors:   ")
   var input string
   fmt.Scanln(&amp;amp;input)
   return strings.ToLower(input)
}

type Move int

const (
   Rock Move = iota
   Paper
   Scissors
)

var validInput = map[string]Move{
   "r":        Rock,
   "rock":     Rock,
   "p":        Paper,
   "paper":    Paper,
   "s":        Scissors,
   "scissors": Scissors,
}

var inputs = [...]string{
   Rock:     "Rock",
   Paper:    "Paper",
   Scissors: "Scissors",
}

func checkInput() Move {
   // start a loop until we get valid input
   for {
      // Does the user input match the map validInput?
      if move, ok := validInput[getInput()]; ok {
         fmt.Println("Player Chooses", inputs[move])
         return move
      }

      fmt.Println("I didn't understand your choice, please retry")
   }

}

var compare = [...]string{
   Rock:     "You Tied.",
   Paper:    "You Lost.",
   Scissors: "You Win!",
}

func main() {
   // for {} says do this until the user wants to stop with ctrl+c which is the universal way to kill a program 
   // that's running in the terminal.
   // this is also known as 'while' loop in other languages and is how video games work (while user playing keep 
   // running game engine) 
   for {
      rand.Seed(time.Now().Unix())

      // Get Valid Player Input
      userChoice := checkInput()

      // Randomly Assign Computer Choice
      computerChoice := Move(rand.Intn(3))

      computerInput := inputs[computerChoice]

      fmt.Printf("Computer chooses: %s\n", computerInput)

      // Check to see who won
      fmt.Printf("Result: %s\n",
         compare[((computerChoice-userChoice)%3+3)%3])
   }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>go</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Ch.2 GO Basics</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Mon, 14 Nov 2022 15:53:31 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch2-go-basics-2lm3</link>
      <guid>https://dev.to/toul-nyc/ch2-go-basics-2lm3</guid>
      <description>&lt;p&gt;In this chapter, I'll cover the basics you'll need for writing programs in GO. Things like using the toolchain, data types, and some handy conversions. I will use plenty of examples in the upcoming sections. It's okay if they do not make sense; we aim for familiarity, not mastery. That said, the best way to learn any programming language is to code along to build muscle memory, so crack open your new installation of Visual Studio Code editor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go/tree/main/ch2" rel="noopener noreferrer"&gt;Chapter 2. GO Basics source code&lt;/a&gt;in case any code causes errors or if you get a little lost.&lt;/p&gt;

&lt;h2&gt;
  
  
  I. The GO Toolchain
&lt;/h2&gt;

&lt;p&gt;One thing that makes developing with GO so vastly different from Python or Java is that it comes with native toolchain support from the creators of the language for an easy way to manage GO codebases. &lt;/p&gt;

&lt;p&gt;In the first chapter, we installed GO, including the toolchain. If you remember, we used 'go build -o' or 'go run main. go' to execute the hello world program, which are &lt;em&gt;commands&lt;/em&gt; that are part of the GO toolchain. &lt;/p&gt;

&lt;p&gt;We'll briefly tour the few commands you use most when writing GO. &lt;/p&gt;

&lt;h3&gt;
  
  
  I.a 'go mod'
&lt;/h3&gt;

&lt;p&gt;Go mod is used for dependency management. It makes it such that when you download another GO project, you'll be guaranteed that the code will work and not be broken due to dependencies.&lt;/p&gt;

&lt;p&gt;Typically, you'll only need to run it every once in a while.&lt;/p&gt;

&lt;p&gt;So here are the two commands you'll need most.&lt;/p&gt;

&lt;h4&gt;
  
  
  go mod init
&lt;/h4&gt;

&lt;p&gt;You use &lt;code&gt;go mod init&lt;/code&gt; to declare that the code you're working on is a &lt;em&gt;module&lt;/em&gt; that requires x,y, and z dependencies; the dependencies will be shown within the &lt;code&gt;go.mod&lt;/code&gt; that is created.&lt;/p&gt;

&lt;p&gt;Typically, you use the format&lt;/p&gt;

&lt;p&gt;&lt;code&gt;go mod init github.com/&amp;lt;yourUserName&amp;gt;/nameOfProject&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  go mod tidy
&lt;/h4&gt;

&lt;p&gt;Go mod tidy eliminates dependencies that aren't used so that your codebase stays light. &lt;/p&gt;

&lt;p&gt;To use it run, &lt;/p&gt;

&lt;p&gt;&lt;code&gt;go mod tidy&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  I.b go get
&lt;/h3&gt;

&lt;p&gt;So, GO requires that the dependencies for a project be installed locally on your machine as you develop and if they aren't then you'll see an error like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ERROR github.com/pkg/name is not installed.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And to solve it run,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;go get github.com/pkg/name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But the catch is that you must have done &lt;code&gt;go mod init&lt;/code&gt; first. &lt;/p&gt;

&lt;h3&gt;
  
  
  I.c 'go fmt'
&lt;/h3&gt;

&lt;p&gt;There are many heated arguments on the internet about how a programming language's codebase should look in terms of format. &lt;/p&gt;

&lt;p&gt;But with GO, there is only one option.&lt;/p&gt;

&lt;p&gt;Imagine, for some reason, that you can't access Visual Studio Code, or the extension stops working, and the go code you wrote from &lt;a href=""&gt;chapter 1. Setting Up Developer Environment&lt;/a&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main 
import "fmt"
func main(){
fmt.Println("Hello, world!")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then to make it GO-compliant, all you'd need to do is,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go fmt main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then your code will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although having a linter like the GO extension installed is preferred to this method, it is good to know for odd occasions when you don't have it.&lt;/p&gt;

&lt;h3&gt;
  
  
  I.d 'go run'
&lt;/h3&gt;

&lt;p&gt;Compiles and runs your GO program all at once very useful when you're working on new code and want instant feedback without having to do 'go build' first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  I.e 'go build'
&lt;/h3&gt;

&lt;p&gt;You'll run this when you've finished your program and want to use it as an executable. When you're done building a Command Line Interface (CLI) tool or a Web App with a server component, you'll want executables. &lt;/p&gt;

&lt;p&gt;And what's better is that with &lt;code&gt;go build&lt;/code&gt;, you can specify which operating systems you want it to run on.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;go build -o hello env GOOS=target-OS GOARCH=target-architecture&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Don't worry if this doesn't make sense right now. Just note that when you want to take your program executable to a different operating system, it is super easy to do by using GOOS and GOARCH &lt;em&gt;environment variables&lt;/em&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  I.f 'go test'
&lt;/h3&gt;

&lt;p&gt;Testing your code speeds up the development process and is often a requirement in the professional world, so having support right out of the box is fantastic.&lt;/p&gt;

&lt;p&gt;Testing is a complete topic worthy of a book or blog post. If you want to look for an in-depth explanation of it, then read my post &lt;a href="https://www.toul.io/golang-tdd/" rel="noopener noreferrer"&gt;GO Test Driven Development&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Otherwise, know that if you see &lt;em&gt;_test.go&lt;/em&gt; files within a codebase that you can run &lt;/p&gt;

&lt;p&gt;&lt;code&gt;go test .&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;To run the tests for that codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  II. Data Types
&lt;/h2&gt;

&lt;p&gt;Computers, unlike humans, need precise instructions. Part of the specificity of the instructions is what data type it is to process. &lt;/p&gt;

&lt;p&gt;So, we'll cover the significant data types in the next section that you'll most likely use and encounter while working with GO. &lt;/p&gt;

&lt;h3&gt;
  
  
  II.a Integers
&lt;/h3&gt;

&lt;p&gt;Integers are your whole numbers, meaning there are no decimal points. &lt;/p&gt;

&lt;p&gt;You use the &lt;em&gt;signed&lt;/em&gt; integer type if a number can be negative. Otherwise, the &lt;em&gt;unsigned&lt;/em&gt; type should be used.&lt;/p&gt;

&lt;h4&gt;
  
  
  Signed
&lt;/h4&gt;

&lt;p&gt;Imagine you have a program to analyze your bank account balance after paying monthly bills, and you've unfortunately had to think about a case where you are negative money.&lt;/p&gt;

&lt;p&gt;You've overspent and might need a credit card, loan, or part of the next paycheck to pay the remainder.&lt;/p&gt;

&lt;p&gt;So, in this case, your result could be &lt;em&gt;negative&lt;/em&gt;, which tells us to use a signed integer. &lt;/p&gt;

&lt;p&gt;First, create a new directory, 'ex1', and then create a new file named 'main.go'. &lt;/p&gt;

&lt;p&gt;And type the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex1
package main

import "fmt"

func pay(money, bills int) int {
   return money - bills
}

func main() {
   var paycheck, bills int = 4000, 5000
   fmt.Printf("bank account balance: %d\n", pay(paycheck, bills))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then run &lt;/p&gt;

&lt;p&gt;&lt;code&gt;go run main.go&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;And you'll see you indeed might have a problem. &lt;/p&gt;

&lt;p&gt;Now that you know when you might use signed integers, it is worth &lt;em&gt;mentioning&lt;/em&gt; that Go lets you specify how many bits an integer can contain with int8,int16, int32, and int64, but for most of the readers, &lt;strong&gt;int&lt;/strong&gt; will more than get the job done.&lt;/p&gt;

&lt;h4&gt;
  
  
  unsigned
&lt;/h4&gt;

&lt;p&gt;Unsigned integers will not be negative, so if we take the same code and swap 'int' with 'uint', you'll see that it breaks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex2
package main

import "fmt"

// changed int to uint
func pay(money, bills uint) uint {
   return money - bills
}
func main() {
   // changed int to uint
   var paycheck, bills uint = 4000, 5000
   fmt.Printf("bank account balance: %d\n", pay(paycheck, bills))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It outputs a nonsensical "18446744073709550616" instead of '-1000' as in the previous example. &lt;/p&gt;

&lt;p&gt;Just like with 'int', there are uint8, uint16, uint32, and uint64 versions, and just like with 'int' most readers will only need 'uint.'&lt;/p&gt;

&lt;h3&gt;
  
  
  Floats
&lt;/h3&gt;

&lt;p&gt;Floats are your decimal numbers; by default, they can handle both positive and negative numbers. In general, I'd use a float for the calculation above because very rarely is anything, only whole numbers. &lt;/p&gt;

&lt;p&gt;I recommend something other than the float if you're on a project where memory is a concern or if you know that decimals will not appear.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex3
package main

import "fmt"

// int -&amp;gt; uint -&amp;gt; float32 if you're coding along
func pay(money, bills float32) float32 {
   return money - bills
}
func main() {
   // int -&amp;gt; uint -&amp;gt; float32
   var paycheck, bills float32 = 4000, 5000.0
   fmt.Printf("bank account balance: %f\n", pay(paycheck, bills))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, there is no 'float' like with 'uint' or 'int', so you must declare either 32bit or 64bit-sized floats. Don't worry float32 will handle most of your use cases. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;An explanation about bits is outside this book's scope, and it isn't necessary to write GO code to automate your daily tasks. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  II.b string
&lt;/h3&gt;

&lt;p&gt;The data you're reading in this book and often contains within documents is of the 'string' data type. And chances are this is the most common data type you'll be using and seeing.&lt;/p&gt;

&lt;p&gt;In GO and many other languages, string types are represented with quotation marks. Like so&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex4
package main

import "fmt"

func main() {
   var example string = "Hello, world!"
   fmt.Printf("%s", example)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  II.c booleans
&lt;/h3&gt;

&lt;p&gt;Boolean variables are either &lt;strong&gt;true&lt;/strong&gt; or &lt;strong&gt;false&lt;/strong&gt;, you'll use this when you're checking for conditions in a program, and we'll use them later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex5
package main

import "fmt"

func main() {
   //Default value will be false
   var a bool
   fmt.Printf("a's value is %t\n", a)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  III. String Concatenation
&lt;/h2&gt;

&lt;p&gt;String concatenation is the idea of adding two strings together to make one string, and as such, it uses the '+' symbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex6
package main

import "fmt"

func main() {
   var s1 string = "Hello "
   var s2 string = "world!"
   fmt.Printf("%s", s1+s2)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  IV. Variables
&lt;/h2&gt;

&lt;p&gt;We've used variables throughout the examples, as shown by the 'var' keyword. Think of a variable like an empty box that you have left over from moving. &lt;/p&gt;

&lt;p&gt;Before you move, you put stuff inside of it, and if you are of the well-organized type, you might even have the same type in one box.&lt;/p&gt;

&lt;p&gt;For example, if packing a box for the kitchen, you might have a box labeled 'kitchen-glasses', and within all glasses from your cabinets.&lt;/p&gt;

&lt;p&gt;So, only one data type goes into the variable, as only glasses go into the kitchen-glasses box. &lt;/p&gt;

&lt;p&gt;And this is how GO expects you to use variables in a very organized manner. &lt;/p&gt;

&lt;p&gt;However, there is a trick that you can use to avoid having to type 'var' and the type the data is explicitly, and that's the ':=', which is called the &lt;strong&gt;short declaration operator&lt;/strong&gt;. But you can only do it within &lt;em&gt;functions&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here's what I mean:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex7
package main

import "fmt"

func pay(money, bills int) int {
   return money - bills
}
func main() {
   // var, int -&amp;gt; :=
   paycheck, bills := 4000, 5000
   fmt.Printf("bank account balance: %d\n", pay(paycheck, bills))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, the 'main()' is a 'func'; hence, we can use the ':=', which is generally the preferred way to save on words. In codebases, less is more.&lt;/p&gt;

&lt;h3&gt;
  
  
  IV.a Assignment statements
&lt;/h3&gt;

&lt;p&gt;Unlike the ':=' that we previously discussed, an assignment statement uses '=', which we used in all the examples, and it requires us to use 'var' and the data type after the variable name.&lt;/p&gt;

&lt;p&gt;E.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex8
package main

import "fmt"

func main() {
   var example string = "Gentle reminder"
   fmt.Printf("%s", example)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this, we are saying that &lt;strong&gt;example&lt;/strong&gt; is a variable of the typed string, and we are &lt;em&gt;assigning&lt;/em&gt; the string "Gentle reminder" to be stored within it. &lt;/p&gt;

&lt;h3&gt;
  
  
  Naming Conventions
&lt;/h3&gt;

&lt;p&gt;Typically, GO programmers prefer short, concise variable names with no '_' or '-', called camelcase and kebob case, respectively.&lt;/p&gt;

&lt;p&gt;So, you'll see terms for variables being as few characters as possible and function names like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex9
package main

import "fmt"

func getUserName() string {
   return "Reader"
}
func main() {
   n := getUserName()
   fmt.Printf("Hello Dear %s", n)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Naming things like this is the opposite of Python's preference for names like 'name_of_user = get_user_name(),' which encourages spelling things out as much as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  V. Type Conversions
&lt;/h2&gt;

&lt;p&gt;Imagine you have data in a document of '1.99' and want to use it as a float for some calculation. Sometimes, you'll find variables and want to change them to another type. Doing so is called casting or conversion in programming speak, and it is probably most familiar with &lt;strong&gt;string&lt;/strong&gt; data.&lt;/p&gt;

&lt;p&gt;Here are a few to keep in mind as you work with GO.&lt;/p&gt;

&lt;h3&gt;
  
  
  golang string to int
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex10
package main

import (
   "fmt"
   "reflect"
   "strconv"
)

func main() {
   strVar := "100"
   intVar, err := strconv.Atoi(strVar)
   fmt.Println(intVar, err, reflect.TypeOf(intVar))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  int to string
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex11
package main

import (
   "fmt"
   "strconv"
)

func main() {
   i := 10
   s1 := strconv.FormatInt(int64(i), 10)
   s2 := strconv.Itoa(i)
   fmt.Printf("%v, %v\n", s1, s2)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  golang bytes array to string
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex12
package main

import "fmt"

func main() {
   s := string([]byte{65, 66, 67, 226, 130, 172})
   fmt.Println(s)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  golang bool to string
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex13
package main

import (
   "fmt"
)

func main() {
   B := true
   str := fmt.Sprintf("%v", B)
   fmt.Println(str)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  VI. Comparisons
&lt;/h2&gt;

&lt;p&gt;They are rarely used alone and typically go with control-flow or conditional statements, which we'll go over later, but I'm showing them here to build familiarity. &lt;/p&gt;

&lt;h3&gt;
  
  
  equal to
&lt;/h3&gt;

&lt;p&gt;Compares whether or not two values stored in variables are equal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex14
package main

import (
   "fmt"
)

func main() {
   fmt.Println("let's see if these two identical strings evaluate to equal")
   s1 := "hi"
   s2 := "hi"
   // okay, I showed a little conditional flow here
   if s1 == s2 {
      fmt.Printf("yes, they are!")
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  not equal to
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex15
package main

import (
   "fmt"
)

func main() {
   fmt.Println("let's see if these two non-identical strings evaluate to equal")
   s1 := "hi"
   s2 := "these are not the droids you're looking for"
   // okay, I showed a little conditional flow here
   if s1 != s2 {
      fmt.Printf("They're not the same string!")
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  greater than
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex16
package main

import (
   "fmt"
)

func main() {
   bills := 13642.32
   paycheck := 10000.00
   if bills &amp;gt; paycheck {
      fmt.Printf("Maybe I should update my resume...")
   }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  less than
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex17
package main

import (
   "fmt"
)

func main() {
   paycheck := 13642.32
   bills := 10000.00
   if bills &amp;lt; paycheck {
      fmt.Printf("alright, alright, alright")
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  greater than or equal to
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex18
package main

import (
   "fmt"
)

func main() {

   bills := 13642.32
   paycheck := 10000.00
   if bills &amp;gt;= paycheck {
      fmt.Printf("I'll never gonna financially recover from this")
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  less than or equal to
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ex19
package main

import (
   "fmt"
)

func main() {
   paycheck := 13642.32
   bills := 10000.00
   if bills &amp;lt;= paycheck {
      fmt.Printf("seems risky.")
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Wow, that was a lot of examples. Congrats on making it this far. Know that as you code along, you are getting more and more comfortable with go! But it's also tiring learning so many new things at once, so make sure to have a snack and rest before heading on to the next chapter.&lt;/p&gt;

&lt;p&gt;Now that all of the basics of GO are in place, we can move on to introducing flow control or logic to our programs. So see you in Chapter 3. with, of course, plenty of examples!&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Ch.1 Developer Environment Set Up</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Mon, 07 Nov 2022 16:14:06 +0000</pubDate>
      <link>https://dev.to/toul-nyc/ch1-developer-environment-set-up-j3j</link>
      <guid>https://dev.to/toul-nyc/ch1-developer-environment-set-up-j3j</guid>
      <description>&lt;p&gt;Hello, all thank you for signing up for the free e-book &lt;a href="https://automatetheboringstuffwithgo.com" rel="noopener noreferrer"&gt;Automate the Boring Stuff with GO&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'll be delivering a chapter each Monday, so keep an eye out. &lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;A developer environment can mean several things, but for you, it means getting your laptop or desktop configured to write GO and run GO programs.&lt;/p&gt;

&lt;p&gt;I'll show you the easiest ways of installing GO for the two most common personal computer operating systems; Windows and macOS.&lt;/p&gt;

&lt;p&gt;Through my years of getting people started, I know package managers are the easiest; a package manager is a tool that makes installing and managing software easier. I recommend this route because the GOPATH tends to trick folks up. But you don't need to worry about that if you follow along. I'll show the links for the package manager for both a Windows and Mac machine.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Notice:&lt;/strong&gt; If you're ever stuck on any code snippets, then make sure to star or bookmark the GitHub Repo &lt;a href="https://github.com/toul-codes/automate-the-boring-stuff-with-go" rel="noopener noreferrer"&gt;Automate the Boring Stuff with GO&lt;/a&gt;,&lt;br&gt;
which will contain all the source codes for each chapter and the text. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So let's get going.&lt;/p&gt;

&lt;h2&gt;
  
  
  I. Installing GO
&lt;/h2&gt;

&lt;h3&gt;
  
  
  I.a Windows
&lt;/h3&gt;

&lt;p&gt;I recommend first installing &lt;a href="https://chocolatey.org/install" rel="noopener noreferrer"&gt;Chocolatey&lt;/a&gt;, which will make installing software on a Windows-based machine effortless.&lt;/p&gt;

&lt;p&gt;To install it, open your Windows Powershell in Administrative mode and paste the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then type the following to install GO:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS C:\ choco install golang
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it's done, then you're ready for part II.&lt;/p&gt;

&lt;h3&gt;
  
  
  I.b MacOSX
&lt;/h3&gt;

&lt;p&gt;For Mac, I recommend first installing &lt;a href="https://brew.sh/" rel="noopener noreferrer"&gt;Brew&lt;/a&gt; if you haven't already.&lt;/p&gt;

&lt;p&gt;To do so, open your Terminal app and type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it's done, do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you're ready for Part II.&lt;/p&gt;

&lt;h2&gt;
  
  
  II. Installing Visual Studio Code (VSC)
&lt;/h2&gt;

&lt;p&gt;Visual Studio Code (VSC) is a text editor. A text editor is standard tool developers use daily to make writing code more manageable. It is similar to how writers use Microsoft Word to create books or essays.&lt;/p&gt;

&lt;p&gt;There are a lot of choices when it comes to text editors, and not all of them are free. We'll stick with Free so that all readers can follow along.&lt;/p&gt;

&lt;p&gt;And the current champ of free text editors is  Microsoft's Visual Studio Code. I recommend using it because there's a lot of support online. And by support, I mean you can ask Dr.Google for help whenever you get stuck.&lt;/p&gt;

&lt;p&gt;Here's the official Visual Studio Code Download &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Click the icon for your Operating System, and  It'll begin installing.&lt;/p&gt;

&lt;p&gt;Once it is done, double-click the Visual Studio Code icon and navigate to the extensions section of VSC.&lt;/p&gt;

&lt;p&gt;Type GO, then click install for the first result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9da7kvd4ucxsnktcygss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9da7kvd4ucxsnktcygss.png" alt="adding-go-extension-visual-studio-code" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This extension will provide automatic syntax highlighting and formatting, similar to how Microsoft's Word provides the red squiggle when you've mistyped a word.&lt;/p&gt;

&lt;p&gt;Once it has finished installing, you're ready for the next part.&lt;/p&gt;

&lt;h2&gt;
  
  
  III. Writing 'Hello World'
&lt;/h2&gt;

&lt;p&gt;Before we write your first program, let's verify that go is installed and accessible within VSC.&lt;/p&gt;

&lt;p&gt;Open a new terminal within VSC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05zhw2rwpmcsykoydpjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05zhw2rwpmcsykoydpjm.png" alt="Visual Studio Code Terminal" width="800" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And press 'enter,' and you'll see something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6v75f2wnytnz9qrc8m4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6v75f2wnytnz9qrc8m4.png" alt="go-installed-successfully" width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don't, reach out to me on Twitter @toul_codes, and I'll try my best to help debug what's happening.&lt;/p&gt;

&lt;p&gt;Now that we've confirmed everything is lined up, it's time to write your first GO program.&lt;/p&gt;

&lt;p&gt;First, create a new file within VSC (cmd + n / ctrl + n) and type out the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main 
import "fmt"

func main() {
   fmt.Println("Hello, world!")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then hit (cmd + s/ctrl + s) and save it as 'main.go'.&lt;/p&gt;

&lt;p&gt;Then on the terminal, type out the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init github.com/&amp;lt;your-name&amp;gt;/automate-the-boring-stuff-with-go-ch1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; This is using one of the features of the GO toolchain that manages dependencies. A dependency is someone else's code you use to save time writing your own code. In this case, the GO developer team and the formatting package named 'fmt.'&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't worry if it doesn't make sense. The next chapter will investigate the GO toolchain and its most valuable features.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After the command is done running, you'll see a &lt;strong&gt;go.mod&lt;/strong&gt; file next to your &lt;em&gt;main.go&lt;/em&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwu4hs0ybxf7caojy2tb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwu4hs0ybxf7caojy2tb.png" alt="go-mod-file" width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in it, you'll see that your program requires &lt;code&gt;go 1.19.3&lt;/code&gt; or whichever version of GO you have installed. Don't worry; any version will work; that's the beauty of GO.&lt;/p&gt;

&lt;p&gt;Now, you can compile your GO program and run it like so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; go build -o hello
&amp;gt; ./hello
Hello, world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, and the way I usually do it to save a step is to type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; go run main.go 
Hello, world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will build and then execute your GO program all at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Wow! You've just tackled a lot of topics as a budding developer. This is a lot to take in for the first time. If your brain is aching, remember that's normal. So, take a snack break or a rest to reward yourself before going on to the next chapter. If you're feeling social, send me a &lt;a href="https://twitter.com/toul_codes" rel="noopener noreferrer"&gt;Tweet&lt;/a&gt; with your celebratory snack of choice!&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introducing Automate the Boring Stuff with GO</title>
      <dc:creator>Toul</dc:creator>
      <pubDate>Fri, 04 Nov 2022 13:20:54 +0000</pubDate>
      <link>https://dev.to/toul-nyc/introducing-automate-the-boring-stuff-with-go-5ehm</link>
      <guid>https://dev.to/toul-nyc/introducing-automate-the-boring-stuff-with-go-5ehm</guid>
      <description>&lt;h2&gt;
  
  
  Welcome to the Free E-book for Beginner Coders Interested in GO
&lt;/h2&gt;

&lt;p&gt;If you're new to GO and a &lt;strong&gt;Beginner&lt;/strong&gt; in programming then there's not really books or learning resources for you. Most GO related books expect you to have &lt;em&gt;some&lt;/em&gt; programming experience and involve complex topics such as Web Application building. &lt;/p&gt;

&lt;p&gt;If you're looking around in the GO communities online for advice, you'll hear things like 'just do the tour' or 'build it yourself' or the worst 'GO is so easy you can learn it in a day', which for a beginner isn't helpful at all and is discouraging.&lt;/p&gt;

&lt;p&gt;However, with &lt;a href="https://www.automatetheboringstuffwithgo.com/" rel="noopener noreferrer"&gt;Automate the Boring stuff with GO&lt;/a&gt; we'll start from the basics of setting your development environment, go over GO, and then at the end build a bunch of useful programs.&lt;/p&gt;

&lt;p&gt;Here's the outline for the &lt;strong&gt;second part&lt;/strong&gt; of the book which contains the programming projects:&lt;/p&gt;

&lt;p&gt;Part II. Ready, Set, GO&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chapter 8.  Regex&lt;/li&gt;
&lt;li&gt;Chapter 9.  Reading and writing files&lt;/li&gt;
&lt;li&gt;Chapter 10. Massive File management&lt;/li&gt;
&lt;li&gt;Chapter 11. Downloading internet pages&lt;/li&gt;
&lt;li&gt;Chapter 12. Excelling with GO - working with Spreadsheets&lt;/li&gt;
&lt;li&gt;Chapter 13. Working with PDF and Word documents&lt;/li&gt;
&lt;li&gt;Chapter 14. Working with CSV and JSON&lt;/li&gt;
&lt;li&gt;Chapter 15. Getting a Grip on Dating&lt;/li&gt;
&lt;li&gt;Chapter 16. Automate E-mailing and Texting&lt;/li&gt;
&lt;li&gt;Chapter 17. Edit PNG and JPEGs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first part will be all about the basics of GO and getting your computer ready to develop code. &lt;/p&gt;

&lt;p&gt;Part I. All you need to get &lt;em&gt;Going&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chapter 1. Setting up your Dev env&lt;/li&gt;
&lt;li&gt;Chapter 2. Basics of GO&lt;/li&gt;
&lt;li&gt;Chapter 3. Flow Control&lt;/li&gt;
&lt;li&gt;Chapter 4. Functions&lt;/li&gt;
&lt;li&gt;Chapter 5. Slices&lt;/li&gt;
&lt;li&gt;Chapter 6. Maps and Structs&lt;/li&gt;
&lt;li&gt;Chapter 7. String Manipulation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Work in progress
&lt;/h2&gt;

&lt;p&gt;I'm writing this book in the open and will deliver one chapter a week, but please bear with me as this is my first time taking on such a task, so the writing might not be perfect. &lt;/p&gt;

&lt;p&gt;But, that also means you can tell me when you're confused, and I'll go back to that chapter / section and add more to it or redo it altogether if it doesn't make sense.&lt;/p&gt;

&lt;p&gt;So, without further ado here's the first chapter!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.automatetheboringstuffwithgo.com/chapter-0-introduction/" rel="noopener noreferrer"&gt;Chapter 0. Introduction&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
