This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (cs *Connections) Update(name string) { | |
// 同名の接続情報が存在するか確認 | |
// 存在していた場合のみ更新 | |
conns := *cs | |
for key, conn := range conns { | |
if conn.Name == name { | |
conns[key].Host, conns[key].User, conns[key].Password = foundation.UpdatePrompt(conn.Host, conn.User, conn.Password) | |
break | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (cs *Connections) Add(name string) { | |
// 同名の接続情報があった場合にエラー | |
if cs.Exist(name) { | |
foundation.PrintError("Connection name already exists") | |
} | |
// Prompterを用いてユーザーの入力値を取得 | |
host, user, password := foundation.AddPrompt() | |
// 接続情報管理ファイルに書き込み |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Connection struct { | |
Name string `yaml:"name"` | |
Host string `yaml:"host"` | |
User string `yaml:"user"` | |
Password string `yaml:"password"` | |
} | |
type Connections []Connection | |
// Load connections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foundation | |
import ( | |
"os" | |
"github.com/mitchellh/go-homedir" | |
) | |
var ( | |
homeDir, _ = homedir.Dir() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- MODEL ---- | |
type alias Model = | |
{ actresses : List Actress | |
, searchParams : List String | |
, paginatedActresses : PaginatedList Actress -- Paginateに使用するModelのListを設定 | |
} | |
init : () -> ( Model, Cmd Msg ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- UPDATE ---- | |
type Msg | |
= NewActresses (Result Http.Error (List Actress)) | |
update : Msg -> Model -> ( Model, Cmd Msg ) | |
update msg model = | |
case msg of | |
-- リクエスト成功時処理 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"fmt" | |
"sync/atomic" | |
) | |
var ( | |
balance int32 = 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"fmt" | |
) | |
var ( | |
balance int32 = 100 | |
wg = sync.WaitGroup{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
// シグナルを受け取るまで待ち受けるためのChannel | |
doneCh := make(chan struct{} | |
t := tebata.New(syscall.SIGINT, syscall.SIGTERM) | |
t.Reserve(func(doneCh chan struct{}){ | |
doneCh <- struct{}{} | |
}, doneCh) | |
// メッセージを受け取る処理をgoroutineで動かす |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t := tebata.New(syscall.SIGINT, syscall.SIGTERM) | |
t.Reserve( | |
// 実行予定関数 | |
func(first, second) { | |
fmt.Println(strconv.Itoa(first + second)) | |
}, | |
1, 2, // 引数 | |
) |