O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Open the console and create the folder chapter02/recipe09.
  2. Navigate to the directory.
  3. Create the case.go file with the following content:
        package main        import (          "fmt"          "strings"          "unicode"        )        const email = "ExamPle@domain.com"        const name = "isaac newton"        const upc = "upc"        const i = "i"        const snakeCase = "first_name"        func main() {          // For comparing the user input          // sometimes it is better to          // compare the input in a same          // case.          input := "Example@domain.com"          input = strings.ToLower(input)          emailToCompare := strings.ToLower(email)          matches := input == emailToCompare          fmt.Printf("Email matches: %t\n", matches)          upcCode := strings.ToUpper(upc)          fmt.Println("UPPER case: " + upcCode)           // This digraph has different upper case and // title ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required