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
assert.Equal(t, got, tt.want, "they should be equal") |
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 main | |
import ( | |
"fmt" | |
) | |
type Node struct { | |
Value int | |
} |
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
type Customer struct { | |
ID int | |
Email string | |
Phone string | |
Age int | |
} | |
func GetCustomerByEmail(db *sql.DB, email string) (*Customer, error) { | |
stmt, err := db.Prepare("SELECT id, email, phone, age FROM customer where email = ?") | |
if err != nil { |
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
type Customer struct { | |
ID int | |
Email string | |
Phone sql.NullString | |
Age sql.NullInt64 | |
} |
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
fmt.Println(customer.Phone.Value) |
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 nt mysql.NullTime | |
err := db.QueryRow("SELECT time FROM foo WHERE id = ?", id).Scan(&nt) | |
if nt.Valid { | |
// use nt.Time | |
} else { | |
// NULL value | |
} |
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
db, err := sql.Open("mysql", "root:@/?parseTime=true") | |
var myTime time.Time | |
db.QueryRow("SELECT current_timestamp()").Scan(&myTime) | |
fmt.Println(myTime.Format(time.RFC3339)) |
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
docker run -d -p 8123:8123 -p 9000:9000 --name some-clickhouse-server --ulimit nofile=262144:262144 yandex/clickhouse-server |
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 main | |
import ( | |
"os" | |
"github.com/org/repo/pkg/cli" | |
) | |
func main{ | |
log.Fatal(cli.Run()) | |
} |
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
syntax = "proto3"; | |
package pb; | |
service Notificator { | |
rpc SendEmail (SendEmailRequest) returns (SendEmailReply); | |
} | |
message SendEmailRequest { | |
string email = 1; |