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 (s *server) Example(ctx context.Context, in *pb.Request) (*pb.Response, error) { | |
// Server側のページネーションメッセージ | |
paginationMessage := &pb.ServerPaginationMessage{ | |
Page: 2, | |
Limit: 20, | |
Size: 100, | |
First: &pb.PaginationMessage{ Page: 1, Limit: 20 }, | |
Last: &pb.PaginationMessage{ Page: 5, Limit: 20 }, | |
Next: &pb.PaginationMessage{ Page: 3, Limit: 20 }, | |
Prev: &pb.PaginationMessage{ Page: 1, Limit: 20 }, |
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
message Response { | |
google.protobuf.Any pagination = 1; | |
} | |
// Server側レスポンス | |
message ServerPaginationMessage { | |
uint32 page = 1; | |
uint32 limit = 2; | |
uint32 size = 3; | |
PaginationMessage first = 4; |
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
rpc Example (Request) returns (Response) { | |
option (google.api.http) = { | |
get: "/example" | |
}; | |
} |
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
message Response { | |
uint32 page = 1; | |
uint32 limit = 2; | |
uint32 size = 3; | |
string first = 4; // 1ページ目URL | |
string last = 5; // 最終ページURL | |
string next = 6; // 次ページURL | |
string prev = 7; // 前ページURL | |
} |
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
message Response { | |
uint32 page = 1; // 現在のページ数 | |
uint32 limit = 2; // ページに表示するアイテム数 | |
uint32 size = 3; // 全てのアイテム数 | |
PaginationMessage first = 4; // 1ページ目情報 | |
PaginationMessage last = 5; // 最終ページ情報 | |
PaginationMessage next = 6; // 次ページ情報 | |
PaginationMessage prev = 7; // 前ページ情報 | |
} |
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 makeApp() *cli.App { | |
app := cli.NewApp() | |
app.EnableBashCompletion = true | |
app.BashComplete = func(ctx *cli.Context) { | |
// 接続名を展開して出力 | |
conns := connection.Load() | |
for _, conn := range conns { | |
fmt.Println(conn.Name) | |
} | |
} |
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
const ( | |
completionDir = "/etc/bash_completion.d" | |
completionFile = "en" | |
completionFileContent = ` | |
_cli_bash_autocomplete() { | |
local cur opts base | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) |
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 makeApp() *cli.App { | |
app := cli.NewApp() | |
// bash-completionの有効化 | |
app.EnableBashCompletion = true | |
return app | |
} |
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 (c *Connection) Connect() { | |
// 接続情報を用いてセッションの確立 | |
session, err := connect(c.User, c.Password, c.Host, 22) | |
if err != nil { | |
foundation.PrintError("Failed to connect.\nReason: " + err.Error()) | |
} | |
defer session.Close() | |
// SSH擬似端末をrawモードで立ち上げる | |
fd := int(os.Stdin.Fd()) |
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) Delete(name string) { | |
var newConns Connections | |
for _, conn := range *cs { | |
// 指定した接続情報を除外し、接続情報配列を組み立てる | |
if conn.Name != name { | |
newConns = append(newConns, conn) | |
} | |
} | |
save(&newConns) | |
} |