`dogo` นายแก้ code ไปส่วนเรา compile+run เอง !!!

Seksit Supakunanon
Tech INNO
Published in
2 min readMay 23, 2020
Photo by SQUARELY on Unsplash

สวัสดีครับเหล่าชาว (golang) developer เคยเป็นไหมครับเวลาเราแก้ code แล้วเราลืม compile+run code หลังจากการแก้ไข code ส่วนเราก็เอ๋ทำไม output ไม่เปลี่ยนทั้งๆที่แก้ไข code ไปแล้วนั่นก็คือคุณเขียน code ผิดยังไงหล่ะ 5555(ล้อเล่นครับ ทำหน้าเจื๋อนไม่มีคนเล่นด้วย (-_-)) แต่เป็นเพราะคุณลืม compile+run code ใหม่อีกรอบ นั่นแหละครับท่านผู้ชมเพราะปัญหานี้เจ้า dogo จึงเกิดมาเพื่อแก้ไขปัญหานี้

`dogo` ไว้ทำหน้าที่ Monitoring การเปลี่ยนแปลงของ Source Code และจะทำการ Compile + Run ให้เราอัตโนมัติ

ส่วน dogo นั้นใช้งานยังไงไปดูกันเลย

  1. install dogo
go get github.com/liudng/dogo

เมื่อ install สำเร็จแล้วแล้วจะสามารถใช้คำสั่ง dogo ได้

install dogo

2. สร้างไฟล์ dogo.json ไว้ใน project ของเรา แล้วใส่รายละเอียดตามนี้

{
"WorkingDir": ".",
"SourceDir": [
"."
],
"SourceExt": [".c", ".cpp", ".go", ".h"],
"BuildCmd": "go build main.go",
"RunCmd": "./main",
"Decreasing": 1
}
create dogo.json file

อธิบายคำสั่ง:

WorkingDir: working directory, dogo will auto change to this directory.
SourceDir: the list of source directories.
SourceExt: monitoring file type.
BuildCmd: the command of build and compile.
RunCmd: the program (full) path.
Decreasing: Ignore the number of modifies, it’s only start counting after build success. Now it’s supported in linux and windows.

เพียงเท่านี้เราก็พร้อมใช้งาน `dogo`

3. ใช้คำ dogo ที่ terminal ให้ตรงกับ path project ของเรา

dogo command

เมื่อใช้คำสั่ง dogo เรียบร้อยแล้วเราสามารถแก้ไข source code ของเราได้ตามใจชอบแล้วเมื่อแก้ไขเสร็จเรียบร้อยตัว dogo จะทำการ compile+run code ให้เราเราสามารถเล่นได้เลย ไม่จำเป็นต้อง terminate + build + run ใหม่อีกรอบให้เสียเวลา

เป็นยังไงครับ ลง+ใช้งาน dogo ง่ายนิดเดียว เพียงเท่านี้เราก็จะไม่ลืม run code ใหม่เวลาแก้ code เรียบร้อย

--

--