ghz
:- Simple
gRPC
benchmarking and load testing tool inspired by hey
and grpcurl
.sample
ghz
command to load test a service:ghz --insecure --proto my_proto.proto --call my_proto.AService.MethodById -d '{"user_id": "5d32b19b6fea7a28de186b15"}' 0.0.0.0:9000
The sample output will be:
Summary:
Count: 200
Total: 557.11 ms
Slowest: 319.18 ms
Fastest: 33.30 ms
Average: 132.56 ms
Requests/sec: 358.99
Response time histogram:
33.300 [1] |
61.887 [6] |∎∎
90.475 [98] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
119.062 [23] |∎∎∎∎∎∎∎∎∎
147.650 [12] |∎∎∎∎∎
176.238 [10] |∎∎∎∎
204.825 [7] |∎∎∎
233.413 [12] |∎∎∎∎∎
262.000 [9] |∎∎∎∎
290.588 [9] |∎∎∎∎
319.176 [13] |∎∎∎∎∎
Latency distribution:
10% in 70.25 ms
25% in 83.84 ms
50% in 89.90 ms
75% in 178.51 ms
90% in 275.84 ms
95% in 301.41 ms
99% in 317.01 ms
Status code distribution:
[OK] 200 responses
#grpc #loadtest #ghz #grpcurl #hey #proto
Tech C**P
ghz: - Simple gRPC benchmarking and load testing tool inspired by hey and grpcurl. sample ghz command to load test a service: ghz --insecure --proto my_proto.proto --call my_proto.AService.MethodById -d '{"user_id": "5d32b19b6fea7a28de186b15"}' 0.0.0.0:9000…
you can give
--format json
option to ghz
in order to get average response time or the slowest in order to use in gitlab
pipelines for examplegolang practical programming course:
https://www.youtube.com/watch?v=G3PvTWRIhZA&list=PLQVvvaa0QuDeF3hP0wQoSxpkqgRcgxMqX
#golang #course #youtube
https://www.youtube.com/watch?v=G3PvTWRIhZA&list=PLQVvvaa0QuDeF3hP0wQoSxpkqgRcgxMqX
#golang #course #youtube
YouTube
Introduction - Go Lang Practical Programming Tutorial p.1
Hello and welcome to a Go Language programming tutorial. In this series, we're going to cover setting up and the basics of using Go in a practical way. Go is a programming language where you could easily run through the basics, and then be totally lost when…
os.Rename
in goLang
?Function signature:
func Rename(oldpath, newpath string) error
What
Rename
does?Rename
renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename
replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. If there is an error, it will be of type *LinkError
.#golang #go #os #rename #os_rename
🛑 Guys from now on you may hear more about
Golang
than Python
for few months ahead. :)As you may already know in
In golang you need to use
#python #golang #go #fmt #sprintf #format
Python
you can format your string using format
as below:file_name = "/root/openvpn/{}.ovpn".format(my_file_name)
// Or
file_name = "/root/openvpn/%s.ovpn" % my_file_name
In golang you need to use
Sprintf
method of fmt
package like follow:var fileName = fmt.Sprintf("/root/openvpn/%s.ovpn", myFileName)
#python #golang #go #fmt #sprintf #format
Echo
: High performance, minimalist Go web framework - https://echo.labstack.com
- https://github.com/labstack/echo
A sample hello-world web server using
Echo
:package main
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
// Echo instance
e := echo.New()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Routes
e.GET("/", hello)
// Start server
e.Logger.Fatal(e.Start(":1323"))
}
// Handler
func hello(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
}
environments in
To set a key/value pair, use
Use
#golang #go #env #environment #environment_variables #range #setenv #getenv #environ
Golang
:To set a key/value pair, use
os.Setenv
. To get a value for a key, use os.Getenv
. This will return an empty string if the key isn’t present in the environment.Use
os.Environ
to list all key/value pairs in the environment. This returns a slice of strings in the form KEY=value
. You can strings.Split
them to get the key and value. Here we print all the keys:package main
import (
"os"
"strings"
"fmt"
)
func main() {
os.Setenv("FOO", "1")
fmt.Println("FOO:", os.Getenv("FOO"))
fmt.Println("BAR:", os.Getenv("BAR"))
fmt.Println()
for _, e := range os.Environ() {
pair := strings.Split(e, "=")
fmt.Println(pair[0])
}
}
#golang #go #env #environment #environment_variables #range #setenv #getenv #environ
If you want to implement "Python Capitalize" method in
There is another method called ToTitle which is used for one character long (but to letters):
#python #golang #go #ToLower #Title #strings #capitalize #ToTitle
Go
:strings.Title(strings.ToLower("MYNAME")) // output: Myname
There is another method called ToTitle which is used for one character long (but to letters):
str := "dz"
fmt.Println(strings.ToTitle(str)) // output: Dz
#python #golang #go #ToLower #Title #strings #capitalize #ToTitle
drop by drop and your bucket gets filled up
یکی از اساتید جمله بالارو مطرح کرده بودند که به نظر من میتونه زندگی بعضی هارو متحول کنه! موضوع بحث اینه که شما قطره قطره به یادگیری خودتان اضافه کنید و در این امر ممارست به خرج بدید و برنامه ریزی مدون داشته باشید. شک نکنید، شک نکنید که به مقصود خودتان خواهید رسید. اگر بخواهیم در کانتکست برنامه نویسی صحبت کنیم یک زبان جدید را در نظر بگیرید که قرار است فرابگیرید. چطور میتوانید یک زبان جدید را مثل زبانی که الان به آن مسلط هستید یاد بگیرید؟ آیا باید زندگی را تعطیل کنید و مسئله جدید را یاد بگیرید؟ نه اصلا اینگونه نیست، تنها کافیست بصورت قطره چکانی هر روز به آن مبحث بپردازید. فقط کافیست هر روز نهال نو پا را آب دهید و به آن برسید این درخت قرار نیست یک روزه تنومند شود و یکروزه میوه دهد تنها برنامه ریزی، تمرین و ممارست شما را به سر منزل مقصود خواهد رساند. تنها کافیست روزی یک ساعت برای آن وقت بگذارید و آخر سال ببینید به کجا رسیده اید. drop by drop!
#motivation #motivational_speaking #life_changing
A very great talk by
- https://www.youtube.com/watch?v=OcjMi9cXItY
#youtube #golang #go #microservice #gomicro #micro
Brian Ketelsen
about microservices using go-micro
:- https://www.youtube.com/watch?v=OcjMi9cXItY
#youtube #golang #go #microservice #gomicro #micro
YouTube
Microservices in Go using Micro - Brian Ketelsen - Codemotion Milan 2017
Go beyond the hype and dig into building microservices with the Go framework Micro (micro.mu). In this talk you’ll learn how to create and deploy microservices using the popular framework Micro, which was extracted out of experience running services at Google…
Slices
are far more efficient than Arrays
in Go
. Assigning one array to another copies all the elements while in Slice
it refers to the underlying Array
. There are major differences between the ways arrays work in
Go
and C
. In Go
,-
Arrays
are values. Assigning one array to another copies all the elements.- In particular, if you pass an
array
to a function, it will receive a copy of the array
, not a pointer to it.- The size of an
array
is part of its type. The types [10]int
and [20]int
are distinct.*NOTE:* The value property can be useful but also expensive; if you want C-like behavior and efficiency, you can pass a pointer to the array.
Read more about
arrays
and slices
here:- https://golang.org/doc/effective_go.html#arrays
#go #arrays #slices
go.dev
Effective Go - The Go Programming Language