Last active
September 4, 2019 15:31
-
-
Save joshuaaguilar20/36f201fbc3a2434842d351f345516b1e to your computer and use it in GitHub Desktop.
Deep D Week 3 Go Lang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 Understand the Native Modules Provided | |
#2 Go is based on using native modules as opposed to using NPM | |
Link To Documents | |
https://golang.org/pkg/ | |
Tuff Concepts | |
-Concurrency | |
-Syntax | |
-Pointers | |
-Structs | |
Starter Concepts | |
--Function in GO Syntax | |
//Every Go Project Starts With Package Main | |
//Must Have Package Main and then Main Function* | |
package main | |
import "fmt" | |
//Ways to Define variables Inside of GO | |
func main(){ | |
//Type long form method | |
//var card string = "Some Random String" | |
//Alternative Way must be creating variable | |
card := "Ace of Spades" | |
newCard:= newCard(); | |
fmt.println(card) | |
} | |
func newCard() string { | |
return "Five of Diamonds" | |
} | |
//Slice and Arr | |
//Every Element in Slice Must be the Same Type* | |
cards := [] string{newCard(),"some Other Card" } | |
//To Add Onto Slice | |
cards = append(cards, "Six of Diamonds"); | |
//How to Loop Over Slice of Cards | |
for i, card := range cards { | |
fmt.println(card) | |
func main(){ | |
//Type long form method | |
//var card string = "Some Random String" | |
//Alternative Way must be creating variable | |
cardGen := newCard(); | |
fmt.Print(cardGen); | |
getInput() | |
//Slice and Arr | |
//Every Element in Slice Must be the Same Type* | |
cards := [] string{newCard(),"some Other Card" } | |
//To Add Onto Slice | |
cards = append(cards, "Six of Diamonds"); | |
//How to Loop Over Slice of Cards | |
for i, card := range cards { | |
fmt.Println(card[i]) | |
} | |
} | |
func newCard() string { | |
return "Five of Diamonds" | |
} | |
func getInput(){ | |
reader := bufio.NewReader(os.Stdin) | |
fmt.Print("Enter text: ") | |
text, _ := reader.ReadString('\n') | |
fmt.Println(text) | |
} | |
Author
joshuaaguilar20
commented
Sep 3, 2019
//Every Go Project Starts With Package Main
//Must Have Package Main and then Main Function*
package main
import (
"fmt"
"bufio"
"os"
"strings"
)
//Ways to Define variables Inside of GO
//Get an Input from the user and check to see if its a prime number or not.
func main(){
getInput()
}
func getInput(){
reader:= bufio.NewReader(os.Stdin)
fmt.Print("What's Your First Name:")
text, _ := reader.ReadString('\n')
name:= text
fmt.Print(name)
if strings.TrimRight(text, "\n") == "Deep" {
fmt.Print("Welcome Deep")
} else {
fmt.Println(text)
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment