SlideShare a Scribd company logo
1 of 23
Download to read offline
15
Golang
@kohei_kimura
Go CLI
• Go
• Go
• A Tour of Go Go
•
• Go
stopho
:
or
go get -d github.com/kohei-kimura/stopho
brew tap kohei-kimura/homebrew-stopho
brew install stopho
stopho →
URL CLI
Go CLI
Go CLI
CLI
CSS
CLI
•
•
•
• …
urfave/cli
CLI
https://github.com/urfave/cli
app.Commands = []cli.Command{
{
Name: "search", // Sub command: `stopho search`
ShortName: "s", // Alias: `stopho s`
Usage: "Generate search URLs from stock photos web sites",
Action: command.CmdSearch,
Flags: []cli.Flag{ // Options
cli.BoolFlag{ // TRUE or FALSE
Name: "japan, j", // `stopho s --japan` or `stopho s -j`
Usage: "Enable Japan mode",
},
cli.StringFlag{ // `stopho s -s $SITE_NAME`
Name: "site, s",
Usage: "Display only sites matched `value`",
},
},
},
}
func CmdSearch(c *cli.Context) {
// Arguments
term := c.Args().Get(0)
// Bool Options
if c.Bool("japan") {
// japan mode
}
// String Options
fmt.Println(c.String("site"))
}
Function
// Set Writer
outStream = new(bytes.Buffer)
app.Writer = outStream
~~~~~~
// Use `fmt.Fprintf`
fmt.Fprintf(c.App.Writer, ...)
Testing
tcnksm/gcli
• CLI
• urfave/cli CLI
Compile by `gox`
•
•
go get github.com/mitchellh/gox
gox
GitHub Releases
1. `Releases`
2. `Create a new release`
3.
4.
Homebew
• ruby
• https://github.com/Homebrew/brew/blob/
master/docs/Formula-Cookbook.md
$ brew create --set-name $APP_NAME $URL
# edit your `$APPNAME.rb`!
$ git push
Framework: urfave/cli
Generator: tcnksm/gcli
Compile tool: mitchellh/gox
Release platform: GitHub Releases
Tips
- e.g. git, docker, …
GIF README.md
reddit twitter
@kohei_kimura
Ɠ IDC
IoT
@kohei_kimura
kohei-kimura
kohei-kimura.github.io
♥ Visual Studio Code
-> ->
IDCF Cloud - IaaS
Enjoy your Go programming!
Please star my Stopho! ->
Please follow me! ->

More Related Content

Similar to 15分で作って配布するGolangコマンドラインツール (6)

Web scraping 101 with goutte
Web scraping 101 with goutteWeb scraping 101 with goutte
Web scraping 101 with goutte
 
Skyfall b sides-c00-l-ed5-sp-2013
Skyfall b sides-c00-l-ed5-sp-2013Skyfall b sides-c00-l-ed5-sp-2013
Skyfall b sides-c00-l-ed5-sp-2013
 
Using Rally for OpenStack certification at Scale
Using Rally for OpenStack certification at ScaleUsing Rally for OpenStack certification at Scale
Using Rally for OpenStack certification at Scale
 
Zagreb workshop
Zagreb workshopZagreb workshop
Zagreb workshop
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Quickly function add by Eclipse Monkey
Quickly function add by Eclipse MonkeyQuickly function add by Eclipse Monkey
Quickly function add by Eclipse Monkey
 

Recently uploaded

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

15分で作って配布するGolangコマンドラインツール