Golang Insights – Telegram
Golang Insights
760 subscribers
116 photos
7 videos
47 files
132 links
Stay ahead in Golang development with Golang Insights, your go-to for the latest news, tips, tricks, and code examples tailored for Golang enthusiasts and professionals.

Group: https://news.1rj.ru/str/GolangEngineers
Download Telegram
🎊 Go 1.22.6 and 1.21.13 are released!

🔈 Announcement: https://groups.google.com/g/golang-announce/c/X4q_-Wf-5g4

⬇️ Download: go.dev/dl/#go1.22.6


☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
3
GoLand 2024.2 is Out!

⚙️ New refactoring
📦 Many fixes for remote development and dev containers
🚀 Performance improvements
🚄DX and UX upgrades
🛰️ Better support for Go frameworks and Go language features

Learn more: https://blog.jetbrains.com/go/2024/08/05/goland-2024-2-is-out/


☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
3
الگوریتم PickByNestedKey


با استفاده از این الگوریتم شما می توانید value مورد نظر خود را از داخل map های تو در تو بکشید بیرون.

این الگوریتم برای مواقعی که شما میخواهید بصورت implicit با دیتا کار کنید و هیچ اطلاعی از تایپ های داخل map ندارید اما value را میخواهید کمک میکند.


https://gist.github.com/Ja7ad/8fd3b33518f571fbe82caa50ec90385f

تست بنچمارک عملکرد:

goos: linux
goarch: amd64
pkg: github.com/Ja7ad/meilisitemap/utils
cpu: AMD Ryzen 7 5700U with Radeon Graphics
Benchmark_PickByNestedKey
Benchmark_PickByNestedKey/foo.bar.x.y.z
Benchmark_PickByNestedKey/foo.bar.x.y.z-16 8992422 133.7 ns/op 80 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo.bar.x.y.a.0.noscript
Benchmark_PickByNestedKey/foo.bar.x.y.a.0.noscript-16 6467626 182.4 ns/op 112 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo.bar.x.y.a.0.domain
Benchmark_PickByNestedKey/foo.bar.x.y.a.0.domain-16 6328083 188.8 ns/op 112 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo.bar.x.y.a.1.noscript
Benchmark_PickByNestedKey/foo.bar.x.y.a.1.noscript-16 6277484 185.9 ns/op 112 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo.bar.x.y.a.1.domain
Benchmark_PickByNestedKey/foo.bar.x.y.a.1.domain-16 6407796 185.7 ns/op 112 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo.bar.x.y
Benchmark_PickByNestedKey/foo.bar.x.y-16 10424744 111.4 ns/op 64 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo.bar
Benchmark_PickByNestedKey/foo.bar-16 15783884 75.94 ns/op 32 B/op 1 allocs/op
Benchmark_PickByNestedKey/foo
Benchmark_PickByNestedKey/foo-16 22246024 52.19 ns/op 16 B/op 1 allocs/op
PASS



☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
6
🥳 Go 1.23.0 is released!

📝 Release notes: go.dev/doc/go1.23

⬇️ Download: go.dev/dl/#go1.23.0


☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
422
7 must-know runtime complexities for coding interviews:

1. 𝐎(1) - 𝐂𝐨𝐧𝐬𝐭𝐚𝐧𝐭 𝐭𝐢𝐦𝐞
- The runtime doesn't change regardless of the input size.
- Example: Accessing an element in an array by its index.

2. 𝐎(𝐥𝐨𝐠 𝐧) - 𝐋𝐨𝐠𝐚𝐫𝐢𝐭𝐡𝐦𝐢𝐜 𝐭𝐢𝐦𝐞
- The runtime grows slowly as the input size increases. Typically seen in algorithms that divide the problem in half with each step.
- Example: Binary search in a sorted array.

3. 𝐎(𝐧) - 𝐋𝐢𝐧𝐞𝐚𝐫 𝐭𝐢𝐦𝐞
- The runtime grows linearly with the input size.
- Example: Finding an element in an array by iterating through each element.

4. 𝐎(𝐧 𝐥𝐨𝐠 𝐧) - 𝐋𝐢𝐧𝐞𝐚𝐫𝐢𝐭𝐡𝐦𝐢𝐜 𝐭𝐢𝐦𝐞
- The runtime grows slightly faster than linear time. It involves a logarithmic number of operations for each element in the input.
- Example: Sorting an array using quick sort or merge sort.

5. 𝐎(𝐧^2) - 𝐐𝐮𝐚𝐝𝐫𝐚𝐭𝐢𝐜 𝐭𝐢𝐦𝐞
- The runtime grows proportionally to the square of the input size.
- Example: Bubble sort algorithm which compares and potentially swaps every pair of elements.

6. 𝐎(2^𝐧) - 𝐄𝐱𝐩𝐨𝐧𝐞𝐧𝐭𝐢𝐚𝐥 𝐭𝐢𝐦𝐞
- The runtime doubles with each addition to the input. These algorithms become impractical for larger input sizes.
- Example: Generating all subsets of a set.

7. 𝐎(𝐧!) - 𝐅𝐚𝐜𝐭𝐨𝐫𝐢𝐚𝐥 𝐭𝐢𝐦𝐞
- Runtime is proportional to the factorial of the input size.
- Example: Generating all permutations of a set.


☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
عکس هایی که کلی حرف توش هست


☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
31
اولین نسخه از زبان GoSharp منتشر شد.

زبان GoSharp یک فورک از Golang هست که قراره فیچرها و بهینه‌سازی‌های زیادی رو داشته باشه.

با اولین فیچری که اضافه شد، شما می‌تونید فقط با نوشتن یک '?' ، خطا رو بدون نوشتن if err != nil برگردونید.

مخزن گیت‌هاب
https://github.com/0x9n0p/gosharp



☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
14811
یا فلت فلت باش یا ساختار دهی کن!!!


زمانی که یک پروژه یا پکیج جدید در زبان Go شروع می‌کنیم، اولین سوالی که پیش می‌آید این است که ساختار یا layout پروژه چگونه باید باشد؟

در زبان Go، هر پوشه یا دایرکتوری می‌تواند به عنوان یک package در نظر گرفته شود. وقتی کدی را در این محدوده می‌نویسید، این کد می‌تواند به طور مستقل از بقیه پروژه تست شود و همچنین به لحاظ دسترسی‌های public/private مدیریت شود.

داشتن یک ساختار منظم برای پروژه بسیار مهم است، اما از همه مهم‌تر این است که بتوانید به گونه‌ای ساختاردهی کنید که به مشکلاتی مانند import cycle برنخورید.

سوالی که برای برخی مطرح است این است که آیا ساختار فلت (flat) خوب است یا نه؟

شاید از دیدگاه بعضی افراد، فلت بودن نشانه‌ای از کمبود دانش فرد در ساختاردهی پروژه باشد، اما باید بدانید که فلت بودن مزایای خاص خود را دارد. البته این مزایا بیشتر در نوشتن پکیج‌ها قابل مشاهده است تا در برنامه‌های اجرایی؛ زیرا در برنامه‌های اجرایی که دارای main هستند، ممکن است با مشکلاتی مواجه شوید. اما برای نوشتن پکیج‌ها، فلت بودن ساختار بسیار مفید است و آزادی بیشتری برای نوشتن یک پکیج خوب به شما می‌دهد.

پس به طور کلی، فلت بودن ساختار برای پکیج‌ها می‌تواند بهتر از داشتن یک ساختار پیچیده باشد.



☄️ @GoInsights | @GolangEngineers
Please open Telegram to view this post
VIEW IN TELEGRAM
2