✅ Pitfalls: avoid unintentional recursion or other issues that could lead to stack overflow json marshal or unmarshal
code:
output:
MarshalJSON person 2 this creates a recursive loop, causing the stack to grow until it exceeds the limit, resulting in a stack overflow error.
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
code:
package main
import (
"encoding/json"
"fmt"
"log"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
type Person2 struct {
Name string `json:"name"`
Age int `json:"age"`
}
func (p *Person) MarshalJSON() ([]byte, error) {
var person Person
person = *p
return json.Marshal(person)
}
func (p *Person2) MarshalJSON() ([]byte, error) {
return json.Marshal(p)
}
func main() {
person := new(Person)
person.Name = "Javad"
person.Age = 29
b, err := person.MarshalJSON()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
person2 := new(Person2)
person2.Name = "Javad"
person2.Age = 29
b, err = person2.MarshalJSON()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
}
output:
{"name":"Javad","age":29}
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020160390 stack=[0xc020160000, 0xc040160000]
fatal error: stack overflow
MarshalJSON person 2 this creates a recursive loop, causing the stack to grow until it exceeds the limit, resulting in a stack overflow error.
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍4💊3
Gopher Academy
✅ Pitfalls: avoid unintentional recursion or other issues that could lead to stack overflow json marshal or unmarshal code: package main import ( "encoding/json" "fmt" "log" ) type Person struct { Name string `json:"name"` Age int `json:"age"`…
What is the maximum stack size for Goroutine?
While the minimum stack size is defined as 2048 bytes, the Go runtime does also not allow goroutines to exceed a maximum stack size; this maximum depends on the architecture and is 1 GB for 64-bit and 250MB for 32-bit systems.
جزئیات مقاله👇♻️
🔷️ https://tpaschalis.me/goroutines-size/
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
While the minimum stack size is defined as 2048 bytes, the Go runtime does also not allow goroutines to exceed a maximum stack size; this maximum depends on the architecture and is 1 GB for 64-bit and 250MB for 32-bit systems.
جزئیات مقاله👇♻️
🔷️ https://tpaschalis.me/goroutines-size/
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍6🍾1
🔵 فلسفه یونیکس میگه:
🟢 «برنامههایی بنویسید که یک کار کوچیک رو به خوبی انجام بدن و باهمدیگه ترکیب بشن.»
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
🟢 «برنامههایی بنویسید که یک کار کوچیک رو به خوبی انجام بدن و باهمدیگه ترکیب بشن.»
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍20🔥4❤2🍾2🕊1
یه برنامه خیلی سبک برای اینکه لاگهای کانتینرهاتون رو بصورت interactive توی browser ببینید ( به جای اینکه توی ترمینال docker log بزنید)
#pythony
https://dozzle.dev
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
#pythony
https://dozzle.dev
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍6🔥2
✅ Go 1.21.4 and 1.20.11 are released!
🗣 Announcement: https://groups.google.com/g/golang-announce/c/4tU8LZfBFkY
🗃 Download: go.dev/dl/#go1.21.4
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
🔐 Security: Includes security fixes for path/filepath (CVE-2023-45283, CVE-2023-45284)
🗣 Announcement: https://groups.google.com/g/golang-announce/c/4tU8LZfBFkY
🗃 Download: go.dev/dl/#go1.21.4
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
💊4
✅ مشارکت و انجام issue به همراه bounty
در زیر تسکی داریم خیلی مهم هستش و همچنین برای شروع مشارکت در پروژه آزاد مناسب می باشد.
https://github.com/pactus-project/pactus/issues/805
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
در زیر تسکی داریم خیلی مهم هستش و همچنین برای شروع مشارکت در پروژه آزاد مناسب می باشد.
https://github.com/pactus-project/pactus/issues/805
توضیحات درخصوص تسک:
ما از کاربران گزارشهای زیادی دریافت کردهایم که نمیتوانند نود خود را اجرا کنند به دلیل خطای 'منبع به طور موقت در دسترس نیست'. این مشکل زمانی پیش میآید که در حال حاضر یک نود در پسزمینه در حال اجرا است و کاربران تلاش میکنند تا یک نود جدید را شروع کنند. ما باید یک راه برای شناسایی اینکه یک نمونه از Pactus در حال اجرا است را پیدا کنیم. اگر چنین است، باید کاربر را قبل از تلاش برای شروع یک نود جدید مطلع کنیم تا از این خطا جلوگیری شود.
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
💊4🔥3👍1
1699469074421.pdf
1 MB
👍6❤1🕊1
✅ آموزش استفاده از go.work و ورژن بندی هر ماژول
در زیر آموزش استفاده از go workspace را قرار دادیم که بتوانید چندین ماژول با ورژن اختصاصی تعریف و داخل pkg.go.dev چطور ثبت کنید.
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
در زیر آموزش استفاده از go workspace را قرار دادیم که بتوانید چندین ماژول با ورژن اختصاصی تعریف و داخل pkg.go.dev چطور ثبت کنید.
مخزن: https://github.com/Ja7ad/go-work
پکیج: https://pkg.go.dev/pkg.go.dev/github.com/Ja7ad/go-work
ماژول ۱: https://pkg.go.dev/github.com/Ja7ad/go-work/mod1
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍5
اگر پرمیوم هستید در تلگرام می توانید با زدن Boost از کانال گوفر آکادمی و گروه مهندسین گولنگ حمایت کنید.
https://t.me/gopher_academy?boost
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
https://t.me/gopher_academy?boost
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
🍾4
#fact
In Go (Golang), the boolean values true and false are untyped bool. This means that unlike many other programming languages, where boolean values have a specific type (e.g., bool), in Go, true and false are untyped. This design choice allows for greater flexibility in certain expressions and comparisons. The constants true and false are defined as untyped bool constants, and they can be used in various contexts without requiring explicit casting to a boolean type. This is a distinctive feature of Go's type system.
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
In Go (Golang), the boolean values true and false are untyped bool. This means that unlike many other programming languages, where boolean values have a specific type (e.g., bool), in Go, true and false are untyped. This design choice allows for greater flexibility in certain expressions and comparisons. The constants true and false are defined as untyped bool constants, and they can be used in various contexts without requiring explicit casting to a boolean type. This is a distinctive feature of Go's type system.
// true and false are the two untyped boolean values.
const (
true = 0 == 0 // Untyped bool.
false = 0 != 0 // Untyped bool.
)
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍3💊2🕊1
دیتابیس PostgreSQL قابلیت Full-Text search داره که خیلی وقت ها میتونه نیازمندی هارو پوشش بده و لازم نباشه سرویسی مثل elasticsearch رو بصورت مجزا استفاده کرد. چون نگهداری و مدیریت هر سرویس جدید هم هزینه نیروی انسانی داره و هم هزینه زمانی و انتقال دانش و کسب تجربه و غیره.
این مقاله قابلیت های دیتابیس PostgreSQL برای Full-Text search رو بیان میکنه
Create an advanced search engine with PostgreSQL
https://xata.io/blog/postgres-full-text-search-engine
#gocasts
#database #postgres
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
این مقاله قابلیت های دیتابیس PostgreSQL برای Full-Text search رو بیان میکنه
Create an advanced search engine with PostgreSQL
https://xata.io/blog/postgres-full-text-search-engine
#gocasts
#database #postgres
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍4❤2🕊2🔥1🍾1
مجموعه نوشتههای درهم و برهم یک محقیق امنیتی در مورد مسایل مختلف که در قالب یک کتاب دراورده شده.
https://ppn.snovvcrash.rocks
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
https://ppn.snovvcrash.rocks
➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍5❤3🔥1🍾1💊1
1698886842698.jpg
179.8 KB
👍2🔥1💊1