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
// init kafka | |
kafkaURL := fmt.Sprintf("%v:%v", configData.Kafka.Host, configData.Kafka.Port) | |
kafkaReader := kafka.NewReader( | |
kafka.ReaderConfig{ | |
Brokers: []string{kafkaURL}, | |
Topic: configData.Kafka.Topic, | |
GroupID: configData.Kafka.GroupID, | |
MaxBytes: configData.Kafka.MaxBytes, | |
}, | |
) |
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
# Created by https://www.toptal.com/developers/gitignore/api/go,intellij,visualstudiocode,vscode | |
# Edit at https://www.toptal.com/developers/gitignore?templates=go,intellij,visualstudiocode,vscode | |
### Go ### | |
# Binaries for programs and plugins | |
*.exe | |
*.exe~ | |
*.dll | |
*.so |
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
ui := ctx.MustGet("user_info").(*model.UserInfo) | |
atClaims := jwt.MapClaims{} | |
atClaims["message"] = "hello" | |
atClaims["userID"] = ui.UserID | |
atClaims["now"] = time.Now().Add(time.Hour * 72).Unix() | |
atClaims["exp"] = time.Now().Add(time.Minute * 15).Unix() | |
var mySigningKey = "ASKS1298dn125568mJQ12=masd=09856nAnD=8J4" | |
token := jwt.NewWithClaims(jwt.GetSigningMethod("HS256"), atClaims) | |
tokenString, err := token.SignedString([]byte(mySigningKey)) |
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
package main | |
import ( | |
"fmt" | |
"regexp" | |
) | |
func main() { | |
str := " -5 + 12 -3 " |
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
/** | |
* Definition for a binary tree node. | |
* type TreeNode struct { | |
* Val int | |
* Left *TreeNode | |
* Right *TreeNode | |
* } | |
*/ | |
func sortedArrayToBST(nums []int) *TreeNode { | |
length := len(nums) |
OlderNewer