# อินเทอร์เฟซใน Go (Go) > อินเทอร์เฟซ, type assertion, type switch, empty interface, error interface - 18 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Go](https://sharpskill.dev/th/technologies/go/interview-questions.md) ## 1. อินเทอร์เฟซใน Go คืออะไร? **คำตอบ** อินเทอร์เฟซใน Go คือชนิดข้อมูลที่กำหนดชุดของ signature เมธอด ชนิดข้อมูลจะ implement อินเทอร์เฟซโดยปริยายด้วยการกำหนดเมธอดทั้งหมดของมัน โดยไม่ต้องประกาศอย่างชัดเจน สิ่งนี้ทำให้เกิดการแยกส่วน (decoupling) ที่แข็งแกร่งและความยืดหยุ่นในการออกแบบโปรแกรม Go ## 2. ชนิดข้อมูล implement อินเทอร์เฟซใน Go อย่างไร? **คำตอบ** ใน Go การ implement อินเทอร์เฟซเป็นแบบโดยปริยาย: ชนิดข้อมูลเพียงแค่ต้องกำหนดเมธอดทั้งหมดของอินเทอร์เฟซ ไม่จำเป็นต้องประกาศอย่างชัดเจน (เช่น 'implements' ใน Java) สิ่งนี้ช่วยให้สามารถเพิ่มอินเทอร์เฟซให้กับชนิดข้อมูลที่มีอยู่แล้วได้โดยไม่ต้องแก้ไขซอร์สโค้ด ## 3. empty interface (interface{}) ใน Go มีอะไรพิเศษ? **คำตอบ** empty interface (interface{}) ไม่ได้กำหนดเมธอดใด ๆ ซึ่งหมายความว่าทุกชนิดข้อมูล implement มันโดยอัตโนมัติ จึงสามารถเก็บค่าของชนิดข้อมูลใดก็ได้ ตั้งแต่ Go 1.18 เป็นต้นมา มันถูกตั้งชื่อแทนด้วยชนิดข้อมูลที่ประกาศไว้ล่วงหน้า 'any' เพื่อความชัดเจนยิ่งขึ้น ## มีอีก 15 คำถาม - ตั้งแต่ Go 1.18 ชื่อแทน (alias) ของชนิดข้อมูล interface{} คืออะไร? - ไวยากรณ์ของ type assertion ใน Go คืออะไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Go อื่นๆ - [พื้นฐาน Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-basics.md): 25 คำถาม, Junior - [โครงสร้างข้อมูล Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-data-structures.md): 20 คำถาม, Junior - [การจัดการข้อผิดพลาด](https://sharpskill.dev/th/technologies/go/interview-questions/error-handling.md): 20 คำถาม, Junior - [พื้นฐาน Goroutine](https://sharpskill.dev/th/technologies/go/interview-questions/goroutines-basics.md): 20 คำถาม, Junior - [Channels](https://sharpskill.dev/th/technologies/go/interview-questions/channels.md): 22 คำถาม, Junior - [Go Modules](https://sharpskill.dev/th/technologies/go/interview-questions/go-modules.md): 18 คำถาม, Mid-Level - [เซิร์ฟเวอร์ HTTP](https://sharpskill.dev/th/technologies/go/interview-questions/http-server.md): 24 คำถาม, Mid-Level - [ไคลเอนต์ HTTP](https://sharpskill.dev/th/technologies/go/interview-questions/http-client.md): 18 คำถาม, Mid-Level - [การเข้ารหัส JSON](https://sharpskill.dev/th/technologies/go/interview-questions/json-encoding.md): 20 คำถาม, Mid-Level - [Database/SQL](https://sharpskill.dev/th/technologies/go/interview-questions/database-sql.md): 22 คำถาม, Mid-Level - [แพ็กเกจ context](https://sharpskill.dev/th/technologies/go/interview-questions/context-package.md): 20 คำถาม, Mid-Level - [Testing](https://sharpskill.dev/th/technologies/go/interview-questions/testing.md): 22 คำถาม, Mid-Level - [รูปแบบ Concurrency](https://sharpskill.dev/th/technologies/go/interview-questions/concurrency-patterns.md): 24 คำถาม, Mid-Level - [ไพรมิทีฟการซิงโครไนซ์](https://sharpskill.dev/th/technologies/go/interview-questions/sync-primitives.md): 22 คำถาม, Mid-Level - [เฟรมเวิร์กเว็บ Go](https://sharpskill.dev/th/technologies/go/interview-questions/go-web-frameworks.md): 20 คำถาม, Mid-Level - [การออกแบบ REST API](https://sharpskill.dev/th/technologies/go/interview-questions/rest-api-design.md): 20 คำถาม, Mid-Level - [gRPC](https://sharpskill.dev/th/technologies/go/interview-questions/grpc.md): 22 คำถาม, Mid-Level - [Reflection](https://sharpskill.dev/th/technologies/go/interview-questions/reflection.md): 20 คำถาม, Senior - [การจัดการหน่วยความจำ](https://sharpskill.dev/th/technologies/go/interview-questions/memory-management.md): 24 คำถาม, Senior - [การเพิ่มประสิทธิภาพการทำงาน](https://sharpskill.dev/th/technologies/go/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [Generics](https://sharpskill.dev/th/technologies/go/interview-questions/generics.md): 20 คำถาม, Senior - [Go Design Patterns](https://sharpskill.dev/th/technologies/go/interview-questions/design-patterns.md): 24 คำถาม, Senior - [Microservices](https://sharpskill.dev/th/technologies/go/interview-questions/microservices.md): 24 คำถาม, Senior - [ความปลอดภัยและการยืนยันตัวตน](https://sharpskill.dev/th/technologies/go/interview-questions/security-authentication.md): 24 คำถาม, Senior - [Docker & Containerization](https://sharpskill.dev/th/technologies/go/interview-questions/docker-containerization.md): 20 คำถาม, Senior - [Kubernetes Basics](https://sharpskill.dev/th/technologies/go/interview-questions/kubernetes-basics.md): 22 คำถาม, Senior - [Go ขั้นสูง](https://sharpskill.dev/th/technologies/go/interview-questions/advanced-go.md): 20 คำถาม, Senior - [การพัฒนา CLI](https://sharpskill.dev/th/technologies/go/interview-questions/cli-development.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/go/interview-questions/go-interfaces