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
| func ClearRow(srv *sheets.Service) { | |
| cvr := &sheets.ClearValuesRequest{} | |
| _, err := srv.Spreadsheets.Values.Clear(spreadsheetId, "Sheet1!A7:E7", cvr).Do() | |
| if err != nil { | |
| log.Fatalf("Unable to clear data from sheet: %v", err) | |
| } | |
| } |
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
| func Update(srv *sheets.Service) { | |
| values := &sheets.ValueRange{ | |
| Values: [][]interface{}{{ | |
| "Japan", | |
| "Software Engineer Lead", | |
| }}, | |
| } | |
| _, err := srv.Spreadsheets.Values.Update(spreadsheetId, "Sheet1!B2:C2", values).ValueInputOption("USER_ENTERED").Do() |
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
| func GetCellValue(srv *sheets.Service) { | |
| values, err := srv.Spreadsheets.Values.Get(spreadsheetId, "Sheet1!A6:E7").Do() | |
| if err != nil { | |
| log.Fatalf("Unable to Get data from sheet: %v", err) | |
| } | |
| fmt.Println(values.Values) | |
| } |
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
| func AppendRow(srv *sheets.Service) { | |
| values := &sheets.ValueRange{ | |
| Values: [][]interface{}{{ | |
| "Timmy", | |
| "Malaysia", | |
| "Software Engineer", | |
| 23, | |
| "05/07/1998", | |
| }}, |
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
| values := &sheets.ValueRange{ | |
| Values: [][]interface{}{{ | |
| "Timmy", | |
| "Malaysia", | |
| "Software Engineer", | |
| 23, | |
| "05/07/1998", | |
| }}, | |
| } |
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
| func main() { | |
| srv := getSheetConfig() | |
| // APPEND ROW | |
| AppendRow(srv) | |
| // GET VALUES | |
| GetCellValue(srv) |
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
| func getSheetConfig() *sheets.Service { | |
| credential, err := json.Marshal(sheetKey) | |
| if err != nil { | |
| log.Fatalf("Failed to get key: %v", err) | |
| } | |
| srv, err := sheets.NewService(context.Background(), option.WithCredentialsJSON(credential)) | |
| if err != nil { | |
| log.Fatalf("Unable to retrieve Sheets client: %v", err) | |
| } |
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
| var ( | |
| spreadsheetId string = "17_V0gRP4z4VE5dHT2u5m44QBCIAUD_ov2i" | |
| sheetKey Key = Key{ | |
| Type: "service_account", | |
| ProjectID: "sheet-projec", | |
| PrivateKeyID: "xxxxx", | |
| PrivateKey: "-----BEGIN PRIVATE KEY-----\xxxxx=\n-----END PRIVATE KEY-----\n", | |
| ClientEmail: "sheet-service-account@xxxxx.iam.gserviceaccount.com", | |
| ClientID: "xxxxx", |
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
| package sessions | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "github.com/go-redis/redis" | |
| "log" | |
| "time" | |
| ) |
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
| func main() { | |
| e := echo.New() | |
| //sessions.SessionsStore = NewMemoryStore() | |
| sessions.SessionsStore = sessions.NewRedisStore() | |
| e.GET("/login", authentication.Login) | |
| g := e.Group("/hello") | |
| //Use Middleware to verify JWT Token |