forked from MichaelCade/90DaysOfDevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83374e5
commit 93185bd
Showing
1,270 changed files
with
320 additions
and
320 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 21 additions & 21 deletions
42
Days/Go/day12_example1.go → 2022/Days/Go/day12_example1.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
challenge := "#90DaysOfDevOps" | ||
const daystotal = 90 | ||
|
||
fmt.Printf("Welcome to %v\n", challenge) | ||
fmt.Printf("This is a %v challenge\n", daystotal) | ||
|
||
var TwitterName string | ||
var DaysComplete int | ||
// ask user for their twitter handle | ||
|
||
TwitterName = "@MichaelCade1" | ||
DaysComplete = 12 | ||
fmt.Printf("%v has completed %v days of the challenge\n", TwitterName, DaysComplete) | ||
fmt.Println("Great work") | ||
} | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
challenge := "#90DaysOfDevOps" | ||
const daystotal = 90 | ||
|
||
fmt.Printf("Welcome to %v\n", challenge) | ||
fmt.Printf("This is a %v challenge\n", daystotal) | ||
|
||
var TwitterName string | ||
var DaysComplete int | ||
// ask user for their twitter handle | ||
|
||
TwitterName = "@MichaelCade1" | ||
DaysComplete = 12 | ||
fmt.Printf("%v has completed %v days of the challenge\n", TwitterName, DaysComplete) | ||
fmt.Println("Great work") | ||
} |
48 changes: 24 additions & 24 deletions
48
Days/Go/day12_example2.go → 2022/Days/Go/day12_example2.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
const DaysTotal int = 90 | ||
challenge := "#90DaysOfDevOps" | ||
|
||
fmt.Printf("Welcome to the %v challenge.\nThis challenge consists of %v days\n", challenge, DaysTotal) | ||
|
||
var TwitterName string | ||
var DaysCompleted uint | ||
|
||
// asking for user input | ||
fmt.Println("Enter Your Twitter Handle: ") | ||
fmt.Scanln(&TwitterName) | ||
|
||
fmt.Println("How many days have you completed?: ") | ||
fmt.Scanln(&DaysCompleted) | ||
|
||
fmt.Printf("Thank you %v for taking part and completing %v days.\n", TwitterName, DaysCompleted) | ||
fmt.Println("Good luck") | ||
} | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
const DaysTotal int = 90 | ||
challenge := "#90DaysOfDevOps" | ||
|
||
fmt.Printf("Welcome to the %v challenge.\nThis challenge consists of %v days\n", challenge, DaysTotal) | ||
|
||
var TwitterName string | ||
var DaysCompleted uint | ||
|
||
// asking for user input | ||
fmt.Println("Enter Your Twitter Handle: ") | ||
fmt.Scanln(&TwitterName) | ||
|
||
fmt.Println("How many days have you completed?: ") | ||
fmt.Scanln(&DaysCompleted) | ||
|
||
fmt.Printf("Thank you %v for taking part and completing %v days.\n", TwitterName, DaysCompleted) | ||
fmt.Println("Good luck") | ||
} |
58 changes: 29 additions & 29 deletions
58
Days/Go/day12_example3.go → 2022/Days/Go/day12_example3.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
const DaysTotal int = 90 | ||
var remainingDays uint = 90 | ||
challenge := "#90DaysOfDevOps" | ||
|
||
fmt.Printf("Welcome to the %v challenge.\nThis challenge consists of %v days\n", challenge, DaysTotal) | ||
|
||
var TwitterName string | ||
var DaysCompleted uint | ||
|
||
// asking for user input | ||
fmt.Println("Enter Your Twitter Handle: ") | ||
fmt.Scanln(&TwitterName) | ||
|
||
fmt.Println("How many days have you completed?: ") | ||
fmt.Scanln(&DaysCompleted) | ||
|
||
// calculate remaining days | ||
remainingDays = remainingDays - DaysCompleted | ||
|
||
fmt.Printf("Thank you %v for taking part and completing %v days.\n", TwitterName, DaysCompleted) | ||
fmt.Printf("You have %v days remaining for the %v challenge\n", remainingDays, challenge) | ||
fmt.Println("Good luck") | ||
} | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
const DaysTotal int = 90 | ||
var remainingDays uint = 90 | ||
challenge := "#90DaysOfDevOps" | ||
|
||
fmt.Printf("Welcome to the %v challenge.\nThis challenge consists of %v days\n", challenge, DaysTotal) | ||
|
||
var TwitterName string | ||
var DaysCompleted uint | ||
|
||
// asking for user input | ||
fmt.Println("Enter Your Twitter Handle: ") | ||
fmt.Scanln(&TwitterName) | ||
|
||
fmt.Println("How many days have you completed?: ") | ||
fmt.Scanln(&DaysCompleted) | ||
|
||
// calculate remaining days | ||
remainingDays = remainingDays - DaysCompleted | ||
|
||
fmt.Printf("Thank you %v for taking part and completing %v days.\n", TwitterName, DaysCompleted) | ||
fmt.Printf("You have %v days remaining for the %v challenge\n", remainingDays, challenge) | ||
fmt.Println("Good luck") | ||
} |
22 changes: 11 additions & 11 deletions
22
Days/Go/day12_example4.go → 2022/Days/Go/day12_example4.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
var challenge = "#90DaysOfDevOps" | ||
|
||
fmt.Println(challenge) | ||
fmt.Println(&challenge) | ||
|
||
} | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
var challenge = "#90DaysOfDevOps" | ||
|
||
fmt.Println(challenge) | ||
fmt.Println(&challenge) | ||
|
||
} |
58 changes: 29 additions & 29 deletions
58
Days/Go/day13_example1.go → 2022/Days/Go/day13_example1.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
const DaysTotal int = 90 | ||
var remainingDays uint = 90 | ||
challenge := "#90DaysOfDevOps" | ||
|
||
fmt.Printf("Welcome to the %v challenge.\nThis challenge consists of %v days\n", challenge, DaysTotal) | ||
|
||
var TwitterName string | ||
var DaysCompleted uint | ||
|
||
// asking for user input | ||
fmt.Println("Enter Your Twitter Handle: ") | ||
fmt.Scanln(&TwitterName) | ||
|
||
fmt.Println("How many days have you completed?: ") | ||
fmt.Scanln(&DaysCompleted) | ||
|
||
// calculate remaining days | ||
remainingDays = remainingDays - DaysCompleted | ||
|
||
fmt.Printf("Thank you %v for taking part and completing %v days.\n", TwitterName, DaysCompleted) | ||
fmt.Printf("You have %v days remaining for the %v challenge\n", remainingDays, challenge) | ||
fmt.Println("Good luck") | ||
} | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
const DaysTotal int = 90 | ||
var remainingDays uint = 90 | ||
challenge := "#90DaysOfDevOps" | ||
|
||
fmt.Printf("Welcome to the %v challenge.\nThis challenge consists of %v days\n", challenge, DaysTotal) | ||
|
||
var TwitterName string | ||
var DaysCompleted uint | ||
|
||
// asking for user input | ||
fmt.Println("Enter Your Twitter Handle: ") | ||
fmt.Scanln(&TwitterName) | ||
|
||
fmt.Println("How many days have you completed?: ") | ||
fmt.Scanln(&DaysCompleted) | ||
|
||
// calculate remaining days | ||
remainingDays = remainingDays - DaysCompleted | ||
|
||
fmt.Printf("Thank you %v for taking part and completing %v days.\n", TwitterName, DaysCompleted) | ||
fmt.Printf("You have %v days remaining for the %v challenge\n", remainingDays, challenge) | ||
fmt.Println("Good luck") | ||
} |
148 changes: 74 additions & 74 deletions
148
Days/Go/day13_example2.go → 2022/Days/Go/day13_example2.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,74 @@ | ||
package main | ||
|
||
import ( | ||
// other imports | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/dghubble/go-twitter/twitter" | ||
"github.com/dghubble/oauth1" | ||
) | ||
|
||
// Credentials stores all of our access/consumer tokens | ||
// and secret keys needed for authentication against | ||
// the twitter REST API. | ||
type Credentials struct { | ||
ConsumerKey string | ||
ConsumerSecret string | ||
AccessToken string | ||
AccessTokenSecret string | ||
} | ||
|
||
// getClient is a helper function that will return a twitter client | ||
// that we can subsequently use to send tweets, or to stream new tweets | ||
// this will take in a pointer to a Credential struct which will contain | ||
// everything needed to authenticate and return a pointer to a twitter Client | ||
// or an error | ||
func getClient(creds *Credentials) (*twitter.Client, error) { | ||
// Pass in your consumer key (API Key) and your Consumer Secret (API Secret) | ||
config := oauth1.NewConfig(creds.ConsumerKey, creds.ConsumerSecret) | ||
// Pass in your Access Token and your Access Token Secret | ||
token := oauth1.NewToken(creds.AccessToken, creds.AccessTokenSecret) | ||
|
||
httpClient := config.Client(oauth1.NoContext, token) | ||
client := twitter.NewClient(httpClient) | ||
|
||
// Verify Credentials | ||
verifyParams := &twitter.AccountVerifyParams{ | ||
SkipStatus: twitter.Bool(true), | ||
IncludeEmail: twitter.Bool(true), | ||
} | ||
|
||
// we can retrieve the user and verify if the credentials | ||
// we have used successfully allow us to log in! | ||
user, _, err := client.Accounts.VerifyCredentials(verifyParams) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Printf("User's ACCOUNT:\n%+v\n", user) | ||
return client, nil | ||
} | ||
func main() { | ||
fmt.Println("Go-Twitter Bot v0.01") | ||
creds := Credentials{ | ||
AccessToken: os.Getenv("ACCESS_TOKEN"), | ||
AccessTokenSecret: os.Getenv("ACCESS_TOKEN_SECRET"), | ||
ConsumerKey: os.Getenv("CONSUMER_KEY"), | ||
ConsumerSecret: os.Getenv("CONSUMER_SECRET"), | ||
} | ||
|
||
client, err := getClient(&creds) | ||
if err != nil { | ||
log.Println("Error getting Twitter Client") | ||
log.Println(err) | ||
} | ||
|
||
tweet, resp, err := client.Statuses.Update("A Test Tweet from the future, testing a #90DaysOfDevOps Program that tweets, tweet tweet", nil) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
log.Printf("%+v\n", resp) | ||
log.Printf("%+v\n", tweet) | ||
} | ||
package main | ||
|
||
import ( | ||
// other imports | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/dghubble/go-twitter/twitter" | ||
"github.com/dghubble/oauth1" | ||
) | ||
|
||
// Credentials stores all of our access/consumer tokens | ||
// and secret keys needed for authentication against | ||
// the twitter REST API. | ||
type Credentials struct { | ||
ConsumerKey string | ||
ConsumerSecret string | ||
AccessToken string | ||
AccessTokenSecret string | ||
} | ||
|
||
// getClient is a helper function that will return a twitter client | ||
// that we can subsequently use to send tweets, or to stream new tweets | ||
// this will take in a pointer to a Credential struct which will contain | ||
// everything needed to authenticate and return a pointer to a twitter Client | ||
// or an error | ||
func getClient(creds *Credentials) (*twitter.Client, error) { | ||
// Pass in your consumer key (API Key) and your Consumer Secret (API Secret) | ||
config := oauth1.NewConfig(creds.ConsumerKey, creds.ConsumerSecret) | ||
// Pass in your Access Token and your Access Token Secret | ||
token := oauth1.NewToken(creds.AccessToken, creds.AccessTokenSecret) | ||
|
||
httpClient := config.Client(oauth1.NoContext, token) | ||
client := twitter.NewClient(httpClient) | ||
|
||
// Verify Credentials | ||
verifyParams := &twitter.AccountVerifyParams{ | ||
SkipStatus: twitter.Bool(true), | ||
IncludeEmail: twitter.Bool(true), | ||
} | ||
|
||
// we can retrieve the user and verify if the credentials | ||
// we have used successfully allow us to log in! | ||
user, _, err := client.Accounts.VerifyCredentials(verifyParams) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Printf("User's ACCOUNT:\n%+v\n", user) | ||
return client, nil | ||
} | ||
func main() { | ||
fmt.Println("Go-Twitter Bot v0.01") | ||
creds := Credentials{ | ||
AccessToken: os.Getenv("ACCESS_TOKEN"), | ||
AccessTokenSecret: os.Getenv("ACCESS_TOKEN_SECRET"), | ||
ConsumerKey: os.Getenv("CONSUMER_KEY"), | ||
ConsumerSecret: os.Getenv("CONSUMER_SECRET"), | ||
} | ||
|
||
client, err := getClient(&creds) | ||
if err != nil { | ||
log.Println("Error getting Twitter Client") | ||
log.Println(err) | ||
} | ||
|
||
tweet, resp, err := client.Statuses.Update("A Test Tweet from the future, testing a #90DaysOfDevOps Program that tweets, tweet tweet", nil) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
log.Printf("%+v\n", resp) | ||
log.Printf("%+v\n", tweet) | ||
} |
Oops, something went wrong.