DEV Community

TypeNaN
TypeNaN

Posted on

01-Go Install

  1. Go download.
    ในที่นี้จะอ้างอิงการติดตั้ง Go ในเวอร์ชั่น 1.19.2 โดยทำการดาวน์โหลดไฟล์จากผู้พัฒนาตามลิงค์ต่อไปนี้
    Go for Linux
    หากต้องการอ่านรายละเอียดเพิ่มเติมจากเว็บไซต์ผู้พัฒนาสามารถเข้าไปอ่านได้ที่นี่เลย https://go.dev

  2. Go install.
    2.1 ลบ Go ที่ติดตั้งไว้ก่อนหน้าออก
    หากไม่แน่ใจว่าเคยติดตั้งมาก่อนแล้วไม่หรือสามารถตรวจสอบมี directory "/usr/local/go" นี้อยู่หรือไม่เนื่องจากการติดตั้ง Go ทับของเดิมที่มีอยู่แล้วจะทำให้ Go พังและการติดตั้งไม่สำเร็จ เพื่อความมั่นใจว่าการติดตั้งจะสำเร็จควรลบ Go ที่ติดตั้งอยู่ออกไปก่อนโดยใช้คำสั่งดังนี้

sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode

2.2 กำหนด PATH ใน Go
กำหนด PATH /usr/local/go/bin เข้าไปในตัวแปรระบบโดยการก็อปปี้ คำสั่งข้างล่างนี้ไปวางไว้ในไฟล์ $HOME/.bashrc หรือ $HOME/.profile หรือ /etc/profile เพียงที่ใดที่หนึ่งเท่านั้น

export PATH=$PATH:/usr/local/go/bin
Enter fullscreen mode Exit fullscreen mode

หากคุณนำไปวางไว้ในไฟล์ $HOME/.bashrc คุณสามารถใช้คำสั่ง source $HOME/.bashrc แล้วทดสอบ Go ได้ทันที หากยังไม่ได้อาจต้อง reboot หรือ login เข้าระบบใหม่อีกครั้งก่อนถึงจะใช้งาน Go ได้

2.3 ยืนยันการติดตั้งสำเร็จ
คุณสามารถตรวจสอบว่าสามารถใช้งาน Go ได้หรือยังด้วยการใช้คำสั่ง

go version
Enter fullscreen mode Exit fullscreen mode

ตัวอย่างผลลัพธ์จากการใช้คำสั่ง go version

go version go1.19 linux/amd64
Enter fullscreen mode Exit fullscreen mode

Go to code.

ได้เวลาเขียน Go กันแล้ว :)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay