{"slug": "goish-ph-rtranaithmkh-ng-go-thangtawlngain-no-std-rust", "title": "Goish: พอร์ตรันไทม์ของ Go ทั้งตัวลงใน no_std Rust", "summary": "Chanwit Kaewkasi, an engineer from Thailand, has released Goish, a Rust runtime that ports Go 1.25's standard library and runtime to no_std Rust, eliminating the garbage collector and relying on Rust's ownership for memory management. The project aims to provide provenance at the function level, addressing compliance requirements like the EU Cyber Resilience Act and FIPS 140-2, by annotating each ported function with its source location in the Go tree and verifying it via CI.", "body_md": "📅 เขียนเมื่อ: สิงหาคม 2026 | Goish (goish.cogentica.ai)\n\n⚠️ โปรเจกต์เพิ่งเปิดตัว — รายละเอียด/เวอร์ชันอาจเปลี่ยนแปลง ตรวจสอบจาก GitHub ก่อนใช้งาน\n\nถ้าคุณเขียน Go มาสักพัก คุณน่าจะเคยอยากได้สองอย่างพร้อมกัน — **concurrency model ของ Go** (goroutine, channel, `select`\n\n) กับ **ความปลอดภัยด้าน memory ของ Rust** (ownership, ไม่มี GC) ปกติแล้วสองอย่างนี้อยู่คนละโลก: Go ให้ runtime มาให้แต่มี garbage collector, Rust ให้ ownership มาแต่ concurrency ต้องประกอบเองจาก async/futures\n\nมีคนพยายามเชื่อมสองโลกนี้เข้าด้วยกันแล้ว — ชื่อโปรเจกต์ว่า **Goish** ผลงานของ **Chanwit Kaewkasi** (@chanwit) วิศวกรชาวไทยจากโคราช ภายใต้บริษัท **Cogentica AI**\n\nนิยามสั้น ๆ ที่เจ้าตัวเขียนไว้ในหน้าแรก: *\"A Rust runtime for Go people\"* — รันไทม์ของ Go สำหรับคนที่เขียน Go\n\nถ้าขยายให้ละเอียด: Goish คือการ**พอร์ต standard library และ runtime ของ Go 1.25 ลงไปใน Rust แบบ no_std** — ไม่พึ่ง glibc, ไม่พึ่ง std ของ Rust, ไม่พึ่ง Tokio, ไม่มี garbage collector มัน ship ทุกอย่างมาเองตั้งแต่\n\n`_start`\n\n, page allocator, size-class heap, M:N scheduler, channel, `select!`\n\n, sync primitives, ไปจนถึง `net/http`\n\nและ `crypto/tls`\n\nผลลัพธ์คือ **binary ไฟล์เดียวแบบ static** เหมือน Go — `ldd`\n\nรันแล้วบอกว่า *\"not a dynamic executable\"*\n\nแต่สิ่งที่ทำให้ Goish ต่างจากโปรเจกต์ \"เขียน Go ให้เป็น Rust\" ทั่วไป คือ**วิธีที่มันให้เครดิตกับต้นทาง** — เรื่องนี้แหละคือหัวใจของที่มาที่ไป\n\nแรงจูงใจหลักไม่ใช่ \"อยากให้ Rust เขียนง่ายเหมือน Go\" ธรรมดา ๆ แต่เป็นเรื่องของ **compliance และ provenance**\n\nลองนึกภาพ: ทีมคุณเขียน Go อยู่ แล้วต้องย้ายไป Rust (ด้วยเหตุผลเรื่อง memory safety หรือนโยบายบริษัท) ระหว่างทางคุณต้อง \"พอร์ต\" โค้ด — เอาโค้ดจาก Go มาเขียนใหม่เป็น Rust แล้วคำถามสำคัญก็ผุดขึ้น:\n\nAES-GCM ใน binary ตัวนี้ เป็น implementation ที่ Go review แล้ว หรือเป็นของที่เราเขียนประมาณเอา?\n\nเครื่องมือ supply-chain ยุคปัจจุบันอย่าง **SLSA provenance** หรือ **SBOM** ตอบคำถามนี้ไม่ได้ — มันอธิบายแค่ว่า binary ถูก build มาจากไหน (builder ไหน, commit อะไร, digest อะไร) แต่**อธิบายไม่ได้ว่าโค้ดข้างในถูก port มาอย่างซื่อสัตย์แค่ไหน** SBOM จะบันทึกว่า \"goish 0.1.0\" แล้วจบ — มันแยกไม่ออกว่า crypto ในนั้นคือของจริงหรือของก๊อป\n\nGoish แก้ด้วยการ**บันทึกที่มาเป็นฟังก์ชันต่อฟังก์ชัน**:\n\n```\n// go: sdk 1.25.5 crypto/internal/fips140/aes/gcm/gcm.go:31-46 newGCM\n```\n\nบรรทัดนี้เขียนไว้เหนือ port แต่ละตัว — บอกว่าโค้ดตรงนี้ port มาจากไฟล์ไหน บรรทัดไหน ใน Go 1.25.5 และมี CI ที่**เปิด Go tree ขึ้นมาเช็คทุก commit** ว่าตำแหน่งที่อ้างยังถูกต้องอยู่\n\nทำไมเรื่องนี้ถึงสำคัญ**ตอนนี้**? เพราะเส้นตายทางกฎหมายกำลังมา:\n\n| วันที่ | เกิดอะไรขึ้น |\n|---|---|\n11 ก.ย. 2026 |\nEU CRA (Cyber Resilience Act) บังคับใช้ภาระการรายงาน — แจ้งเตือน 24 ชม. / แจ้งเต็ม 72 ชม. เมื่อเจอช่องโหว่ที่ถูกโจมตีจริง |\n21 ก.ย. 2026 |\nใบรับรอง FIPS 140-2 ย้ายเข้า \"Historical List\" — ใช้ต่อได้แต่ justify การจัดซื้อภาครัฐใหม่ไม่ได้ |\n1 ม.ค. 2027 |\nCNSA 2.0 กลายเป็นค่าเริ่มต้นสำหรับงาน NSS ของสหรัฐฯ |\n11 ธ.ค. 2027 |\nข้อกำหนดสำคัญของ CRA รวมถึง mandate เรื่อง machine-readable SBOM |\n\nพูดง่าย ๆ: **ถ้าสินค้าคุณต้องผ่าน compliance พวกนี้ คุณต้องพิสูจน์ได้ว่าโค้ดทุกบรรทัดมาจากไหน** — และสำหรับโค้ดที่ \"แปล\" มาจากที่อื่น การพิสูจน์นั้นต้องลงถึงระดับฟังก์ชัน ไม่ใช่ระดับ build\n\nนี่คือเหตุผลที่ Goish เกิด\n\nส่วนนี้คือความเจ๋งทางวิศวกรรม — ถ้าไม่อยากอ่านเชิงลึก ข้ามไปหัวข้อถัดไปได้เลย\n\n`runtime/proc.go`\n\nGoish ไม่ได้ \"เขียน scheduler ใหม่ให้คล้าย Go\" — มัน**แปล runtime/proc.go ของ Go 1.25 มาทีละบรรทัด**:\n\n`runqgrab`\n\n/ `runqsteal`\n\n/ `stealOrder`\n\n)`sysmon`\n\nตัวจัดการ timer heap + force-preemptGoish เอา**โครงสร้าง allocator ของ Go** (mheap → mcentral → per-P mcache, 67 size classes) มาใช้ แต่**ตัด garbage collector ออก** — ให้ Rust ownership เป็นคน reclaim แทน\n\nสำหรับ stack ของ goroutine มันใช้วิธีฉลาด: goroutine หนึ่งตัวได้ virtual reservation **1 MiB** แบบ lazy-commit (kernel ค่อย commit หน้า 4 KiB เมื่อถูกแตะจริง) — แปลว่า goroutine ที่ทำงานตื้น ๆ เสีย memory จริงแค่ประมาณหนึ่ง page และถ้าอยากได้ความหนาแน่นสุดขีด ก็ใช้ `go!(stack(2*KB), …)`\n\nเพื่อขอ stack ขนาด 2 KiB จาก stack pool\n\nผลลัพธ์ตาม demo:\n\n```\nts  vmsize_kb  vmrss_kb  vmpeak_kb  vmhwm_kb  threads\n 0s    1105148      44800    1108444      49024   13   ← baseline\n 2s    3069660    2406528    3069660    2406528   13   ← 1M parked\n30s    3069660    2406528    3069660    2406528   13   ← steady-state\n```\n\n**goroutine หนึ่งล้านตัว บน OS thread แค่ 13 เธรด** — ~2.4 KiB RSS ต่อ goroutine\n\nจุดเด่นที่สุดสำหรับคนเขียน Go — public API ใช้ **type ตัวพิมพ์เล็กแบบ Go** แทน type ของ Rust:\n\n``` php\nfn get(url: string) -> (int, string, string) {\n    let (mut resp, err) = http::Get(url.clone());\n    if err != nil {\n        return (-1, fmt::Sprintf!(\"get %s: %v\", url, err), string(\"\"));\n    }\n    let (body, _) = io::ReadAll(&mut resp.Body);\n    let _ = io::Closer::Close(&mut resp.Body);\n    return (resp.StatusCode, string(body), resp.Header.Get(\"Content-Type\"));\n}\n```\n\n`string`\n\n, `int`\n\n, multi-return, `if err != nil`\n\n— ทั้งหมดคือ Rust จริง ๆ ที่ `rustc`\n\ncompile ได้ แต่**อ่านแล้วแทบไม่ต่างจาก Go** และ `Vec<u8>`\n\nกับ `&str`\n\nไม่โผล่ใน signature สาธารณะเลย\n\nนี่คือ philosophy หลัก: **\"Port first, get idiomatic later\"** — พอร์ตโค้ด Go มาแบบเกือบ line-by-line ก่อน แล้วค่อย ๆ ปรับเป็น Rust idiom ทีละ module เมื่อทีมพร้อม\n\nส่วนที่ภาคภูมิใจที่สุดคือ `crypto/`\n\n— **ครบ 1722/1722 declarations (100%) ทั้ง 66 packages** รวมถึง `crypto/internal/fips140*`\n\nทั้ง 35 packages ที่เป็น code path ของ FIPS validation และ `net/http`\n\nครบ **639/639 functions (100%)**\n\nTLS 1.3 ที่รันจริงคือ `crypto/tls`\n\nที่ port มา verbatim — ไม่ใช่ implementation ใหม่ที่เขียนเลียนแบบ\n\n`scratch`\n\n/distroless container, confidential VM, appliance imageต้องการแค่ **Rust 1.79+** และ **Linux x86_64** (single-target ณ ตอนนี้)\n\n```\ngit clone https://github.com/cogentica-ai/goish\ncd goish\n\n# build library\ncargo build --target x86_64-unknown-linux-gnu --release\n\n# demo: หนึ่งล้าน goroutine\ncargo build --target x86_64-unknown-linux-gnu --release --example spawn_million\n./examples/spawn_million.sh\n\n# goginx: nginx clone ที่เขียนด้วย goish\ncargo build --target x86_64-unknown-linux-gnu --release --example goginx\n```\n\nโค้ด \"Hello\" แบบ Goish หน้าตาประมาณนี้:\n\n```\nuse goish::{fmt, go};\n\n#[goish::main]\nfn main() {\n    go!(move || {\n        fmt::Println!(\"hello from a goroutine\");\n    });\n}\n```\n\n`.go`\n\n`crypto/`\n\nกับ `net/http`\n\nเสร็จแล้ว แต่ `net`\n\n, `encoding`\n\n, `os`\n\nยังบางส่วนGoish ไม่ได้เป็นแค่ \"Go runtime ใน Rust\" — มันเป็นความพยายามตอบคำถามที่ใหญ่กว่านั้น: **เมื่อเราต้องย้ายภาษาในโลกที่มีกฎหมายบังคับเรื่องที่มาของโค้ด เราจะพิสูจน์ได้ยังไงว่าโค้ดทุกบรรทัดไว้ใจได้**\n\nคำตอบของ Chanwit คือการพอร์ต Go แบบมี \"ใบเสร็จ\" ทุกบรรทัด แล้วเอา ownership ของ Rust มาแทน GC — ได้ทั้งความคุ้นเคยของ Go, ความปลอดภัยของ Rust, และหลักฐาน compliance ที่ตรวจซ้ำได้\n\nโปรเจกต์นี้เพิ่งเปิด (สิงหาคม 2026) และยังพัฒนาอย่างต่อเนื่อง ถ้าสนใจเข้าไปดูได้ที่:\n\n**เครดิต:** บทความนี้อ้างอิงข้อมูลจากเว็บไซต์ goish.cogentica.ai และ README ของ github.com/cogentica-ai/goish — โปรเจกต์โดย **Chanwit Kaewkasi** (@chanwit) ภายใต้ **Cogentica AI** (ประเทศไทย)\n\n⚠️ Goish ไม่เกี่ยวข้องกับ Google หรือ Go project — \"Go\" เป็นเครื่องหมายการค้าของ Google LLC", "url": "https://wpnews.pro/news/goish-ph-rtranaithmkh-ng-go-thangtawlngain-no-std-rust", "canonical_source": "https://dev.to/gophernment/goish-phrtranaithmkhng-go-thangtawlngain-nostd-rust-4g0n", "published_at": "2026-08-15 02:40:33+00:00", "updated_at": "2026-08-15 03:10:49.641810+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Chanwit Kaewkasi", "Goish", "Cogentica AI", "Go", "Rust", "EU Cyber Resilience Act", "FIPS 140-2", "SLSA"], "alternates": {"html": "https://wpnews.pro/news/goish-ph-rtranaithmkh-ng-go-thangtawlngain-no-std-rust", "markdown": "https://wpnews.pro/news/goish-ph-rtranaithmkh-ng-go-thangtawlngain-no-std-rust.md", "text": "https://wpnews.pro/news/goish-ph-rtranaithmkh-ng-go-thangtawlngain-no-std-rust.txt", "jsonld": "https://wpnews.pro/news/goish-ph-rtranaithmkh-ng-go-thangtawlngain-no-std-rust.jsonld"}}