<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>Go - หมวดหมู่ - Kawin&#39;s Pages</title>
        <link>https://kawin.dev/categories/go/</link>
        <description>Go - หมวดหมู่ - Kawin&#39;s Pages</description>
        <generator>Hugo -- gohugo.io</generator><language>th</language><managingEditor>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</managingEditor>
            <webMaster>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</webMaster><lastBuildDate>Sat, 08 Nov 2025 12:00:00 &#43;0700</lastBuildDate><atom:link href="https://kawin.dev/categories/go/" rel="self" type="application/rss+xml" /><item>
    <title>รับ interface แล้วคืนค่า struct</title>
    <link>https://kawin.dev/posts/go/accept_interfaces_return_structs/</link>
    <pubDate>Sat, 08 Nov 2025 12:00:00 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/accept_interfaces_return_structs/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.png" referrerpolicy="no-referrer">
            </div><p>ในโลกของการเขียนโปรแกรมด้วย Go การออกแบบฟังก์ชันให้ยืดหยุ่นและดูแลง่ายคือกุญแจสำคัญของการสร้างแอปที่แข็งแรง หนึ่งในแพทเทิร์นที่ทรงพลังมากคือ</p>
<blockquote>
<p>รับค่าเป็น <strong>interface</strong> แล้วคืนค่าเป็น <strong>struct</strong></p></blockquote>
<p>แนวคิดนี้ช่วยให้เทสง่ายขึ้น ลดการผูกติด (coupling) ระหว่างส่วนต่าง ๆ ในระบบ และทำให้โค้ดของเราปรับตัวตาม requirement ที่เปลี่ยนไปได้ดีขึ้นมาก</p>]]></description>
</item>
<item>
    <title>GOMAXPROCS, GOMEMLIMIT กับ Kubernetes</title>
    <link>https://kawin.dev/posts/go/go_kube_resource_limits/</link>
    <pubDate>Wed, 13 Mar 2024 00:45:21 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/go_kube_resource_limits/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p><a href="https://pkg.go.dev/runtime" target="_blank" rel="noopener noreffer ">Go runtime</a> มีค่า ENV ที่สามารถตั้งค่าได้อยู่ไม่กี่ตัว แต่มันจะมีอยู่ 2 ค่าที่ชาว DevOps จะเอามาใช้เป็นค่าเริ่มต้นเลย คือ <strong>GOMAXPROCS</strong> และ <strong>GOMEMLIMIT</strong> โดยแต่ละค่าจะใช้ทำอะไรได้บ้างเรามาลองดูกัน</p>]]></description>
</item>
<item>
    <title>ติดไอพ่นให้ JSON ใน Go</title>
    <link>https://kawin.dev/posts/go/faster_json/</link>
    <pubDate>Mon, 11 Dec 2023 10:00:40 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/faster_json/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/img/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>สิ่งที่ต้องเจอบ่อย ๆ เวลาทำงานกับ REST API นั่นคือการแปลง JSON ไปมาระหว่าง services โดบปกติแล้วก็จะใช้ <code>encoding/json</code> กันซึ่งเป็นไลบรารีมาตรฐานที่มีให้ใน Go แต่ตอนนี้มีของจะมาแนะนำให้ลองกัน นั่นคือ <code>goccy/go-json</code> ที่จะทำให้ services เราเร็วขึ้นโดยไม่ต้องจ่ายตังเพิ่ม</p>]]></description>
</item>
<item>
    <title>GO: io.ReadAll vs io.Copy</title>
    <link>https://kawin.dev/posts/go/readall_vs_buffer/</link>
    <pubDate>Sun, 10 Dec 2023 18:33:40 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/readall_vs_buffer/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>การเขียน Go บ่อยครั้งเราจะเจอการที่เราต้องเปิดอ่านไฟล์หรืออ่าน Response จากการดึง API ซึ่งส่วนใหญ่ โดยทั่วไปแล้วก็จะใช้ io.ReadAll และ io.Copy กัน ตอนนี้จะพาไปดูว่ามันแตกต่างกันอย่างไร</p>]]></description>
</item>
<item>
    <title>จะ Go vs Rust ทำไม ในเมื่อ Go &#43; Rust ได้</title>
    <link>https://kawin.dev/posts/go/rust_ffi/</link>
    <pubDate>Fri, 13 Oct 2023 15:38:13 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/rust_ffi/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>เราจะเจอคำถามประเภทที่ว่า จะใช้อะไรดีระหว่าง Go กับ Rust หลังจากที่ได้ลองเขียนทั้ง Go กับ Rust มาสักพักแล้ว พบว่าเราสามารถใช้ cgo + Rust FFI ได้ ซึ่งในเมื่อทั้งสองมีข้อดีต่างกัน เราก็ใช้มันทั้งสองไปเล๊ยยย</p>]]></description>
</item>
<item>
    <title>GOMAXPROCS เพื่อนที่ดีของ DevOps</title>
    <link>https://kawin.dev/posts/go/automaxprocs/</link>
    <pubDate>Sun, 13 Aug 2023 00:19:58 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/automaxprocs/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>ตั้งแต่ Go 1.5 เป็นต้นมานั้น ค่าของจำนวน <code>User-Level</code> ที่ Go App จะสามารถให้ทำงานพร้อมกันนั้นในแต่ละ Instance จะถูกกำหนดด้วย GOMAXPROCS แล้วทีนี้ค่าของ GOMAXPROCS จะมีค่าตามนิยามนี้
<div class="details admonition note open">
        <div class="details-summary admonition-title">
            <i class="icon fas fa-pencil-alt" aria-hidden="true"></i>Note<i class="details-icon fas fa-angle-right" aria-hidden="true"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content">GOMAXPROCS sets the maximum number of CPUs that can be executing simultaneously and returns the previous setting. It defaults to the value of runtime.NumCPU. If n &lt; 1, it does not change the current setting. This call will go away when the scheduler improves.</div>
        </div>
    </div></p>]]></description>
</item>
<item>
    <title>Go กับการ re-use memory ด้วย sync.Pool</title>
    <link>https://kawin.dev/posts/go/sync_pool/</link>
    <pubDate>Tue, 01 Aug 2023 20:31:34 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/sync_pool/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>ถ้าใครเขียน goroutine ก็คงจะเคยพบเจอกับ <code>sync.WaitGroup</code> ที่ใช้ในการทำ wait group ให้ goroutine กันแล้ว แต่ใน pkg <code>sync</code> มี type นึงที่มีประโยชน์ในงานที่อยากจะมาแนะนำ คือ <code>sync.Pool</code> ที่จะมาช่วย re-use memory ลดการ allocate ที่ต้องใช้ของเดิมซ้ำ ๆ ได้</p>]]></description>
</item>
<item>
    <title>Go กับปัญหาโลกแตก Value หรือ Pointer</title>
    <link>https://kawin.dev/posts/go/value_or_pointer/</link>
    <pubDate>Mon, 31 Jul 2023 18:33:40 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/value_or_pointer/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>ในเวลาที่เขียนภาษา Go มักจะมีคำถามนึงโผล่มาเสมอ คือตกลง func นี้จะใช้ Value หรือ Pointer ดีนะ เดี๋ยวเรามาดูความแตกต่างกัน</p>]]></description>
</item>
<item>
    <title>ออกแบบ Go struct ด้วยความรู้วิชา Computer Architecture และ Data Structure</title>
    <link>https://kawin.dev/posts/go/struct_memory/</link>
    <pubDate>Sun, 30 Jul 2023 13:01:50 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/struct_memory/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.webp" referrerpolicy="no-referrer">
            </div><p>ตอนสมัยเรียนวิศวคอมพิวเตอร์มีคำถามนึงโผล่มาเสมอว่าวิชาอย่าง Computer Architecture กับ Data Structure เรียนไปทำไมกันนะ จนกระทั้งจบออกมาได้เขียนภาษา Go ถึงได้เอะใจว่า ทำไม Go ถึงได้มี data type แบบกำหนดขนาด เช่น <code>int8</code> <code>int16</code> <code>int32</code> <code>int64</code> และอื่น ๆ ทำไมถึงไม่เป็น <code>int</code> หรือ <code>number</code> เฉย ๆ ไปเลยแบบภาษาขี้เกียจอย่าง TypeScript กันนะ จนได้มานั่งอ่านเกี่ยวกับ <a href="https://go.dev/src/go/types/sizes.go" target="_blank" rel="noopener noreffer ">sizes in Go</a> ถึงได้รู้ว่าเราสามารถใช้ความรู้ในวิชา Computer Architecture และ Data Structure มาช่วยให้เราเขียน Go ออกมาได้ประสิทธิภาพอย่างที่ควรจะเป็น</p>]]></description>
</item>
<item>
    <title>เมื่อ Go กับ SOLID มาเจอกัน</title>
    <link>https://kawin.dev/posts/go/solid/</link>
    <pubDate>Sat, 29 Jul 2023 09:16:31 &#43;0700</pubDate>
    <author>kawin.v@kkumail.com (Kawin Viriyaprasopsook)</author>
    <guid>https://kawin.dev/posts/go/solid/</guid>
    <description><![CDATA[<div class="featured-image">
                <img src="/featured-image.jpg" referrerpolicy="no-referrer">
            </div><p>การพัฒนาซอฟต์แวร์ในยุคปัจจุบัน หากเน้นการเร่งทำให้เสร็จเพื่อใช้งานก่อน แล้วค่อยกลับไปเก็บรายละเอียดทีหลัง (ซึ่งส่วนใหญ่ก็ไม่เคยทำได้หมด) มักจะส่งผลให้เมื่อต้องการเพิ่มฟีเจอร์ใหม่ ๆ จะเริ่มรู้สึกว่าการแก้ไขหรือเพิ่มเติมเป็นเรื่องยากลำบาก เพราะโค้ดที่เขียนขึ้นมาอาจจะเชื่อมโยงกันมากเกินไป หรือหากมีความต้องการใช้งานเพิ่มขึ้น ก็อาจจะไม่สามารถขยายระบบได้ตามความต้องการ เนื่องจากการพัฒนาซอฟต์แวร์นั้นขาดการวางแผนหรือโครงสร้างที่ชัดเจน</p>
<p>วันนี้เราจะมาแนะนำแนวทางในการพัฒนาซอฟต์แวร์ที่ช่วยให้โค้ดมีคุณภาพดี, ง่ายต่อการดูแลรักษา และสามารถขยายได้ตามความต้องการ แนวทางที่นิยมและเข้าใจง่ายคือ SOLID ซึ่งในตัวอย่างวันนี้จะใช้ภาษา Go เป็นหลัก (เพราะ Go เป็นภาษาที่ผมถนัดที่สุด)</p>]]></description>
</item>
</channel>
</rss>
