Define database schemas in declarative code. Use HCL, SQL or any ORM or language. Supports all popular ORMs, such as GORM, Sequelize, Django, SQLAlchemy, Hibernate, and more. Test your schemas and migrations using the Atlas testing framework.
« Software Design 2018年7月号「Vim 絶対主義」の執筆に参加しました。 | Main | ボタンを押したら golang の if err... を自動入力 » tensorflow といえば Python と思っておられる方も多いのではないでしょうか。間違いではないのですが、これは初期に作られた Python 向けのバインディングに研究者達が多く食いついた結果に過ぎないと思っています。実際 tensorflow は現在 C言語、C++、Python、Java、Go から利用する事ができ、最近では JavaScript にも移植されています。筆者自身も Go で tensorflow を使ったシステムを構築し、運用保守しています。問題も発生せず機嫌良く動いています。学習の利用部分は GPU のパフォーマンスに依存しますが、それ以外の部分については各言語の実装に依存し
はじめに Go 言語の reflect パッケージは動的に型や値を扱いたい場合に便利です。 このページでは reflect パッケージの詳しい Example をチートシートとしてまとめました。 ご案内 このページの内容を別サイトにまとめなおしました。 目的別に項目を分けたのでやりたいことからコードを逆引きできます。 また、サイト上でコードを即時実行できるように The Go Playground の実行フォームを埋め込んだので、気軽にコードをお試しいただけます。 目次 型情報を値として取得する 型情報を比較する 任意の型の値を引数とする関数を定義する リフレクションで変数を更新する 構造体のフィールド一覧を取得する 構造体のフィールドのタグ情報を取得する ゼロ値であるかを調べる ゼロ値を取得する リフレクションで数値を扱う リフレクションで文字列を扱う リフレクションで配列を扱う リフレ
昨日僕の Twitter タイムラインで q というツールが話題に上がっていました。 GitHub - harelba/q: q - Run SQL directly on CSV or TSV files Text as Data q is a command line tool that allows direct execution of SQL-like q... https://github.com/harelba/q 標準入力を SQL で抽出できるという物です。ただ個人的には「こういうの python じゃなくて Go でビルドされてると助かるよなー」と思ったので q と同じ様な動作になるツールを作ってみました。 GitHub - mattn/qq Select stdin with query https://github.com/mattn/qq 例えば msys2 のシ
package main import ( "github.com/PuerkitoBio/goquery" "fmt" ) func main() { doc, err := goquery.NewDocument("https://github.com/PuerkitoBio/goquery") if err != nil { fmt.Print("url scarapping failed") } doc.Find("a").Each(func(_ int, s *goquery.Selection) { url, _ := s.Attr("href") fmt.Println(url) }) }
Sirupsen/logrus でアクセスログとエラーログを別ファイルにするのに、それぞれに対して logrus.New() しました。呼び出しはそれをラップした関数を通して行います。 package main import ( "github.com/Sirupsen/logrus" // "github.com/k0kubun/pp" "fmt" "net/http" "os" ) var errorLog = logrus.New() var accessLog = logrus.New() func init() { accessLogFile, err := os.OpenFile("access.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { panic(fmt.Sprintf("[Error]:
プログラムが動作中に再度呼ばれると色々良くないので禁止してみます やり方としてはプロセスの起動状態を見るとかあるのですが 今回はロックファイルを作って排他が掛かっていたら エラーで抜けるという方法です golang実装 package main import ( "fmt" "io/ioutil" "os" "syscall" ) func main() { fmt.Println("ready") lockfile := "lock" if _, err := os.Stat(lockfile); err != nil { fmt.Println("make lockfile") ioutil.WriteFile(lockfile, []byte(""), 0644) } fd, _ := syscall.Open("lock", syscall.O_RDONLY, 0000) defe
FINAL FANTASY Record Keeper用に作ったツールのGolang実装についていろいろ。Read less
Designed from scratch for modern environment so implemented in the Go programming language. Multicore CPUs GoBGP is designed to exploit todays multicore processors. Golang makes it extremely easy and simple to write concurrent code. Automation Friendly GoBGP is designed to be easily integrated with other software with its RPC APIs instead of manually changing its config via CLI. GoBGP also support
Anyone who spends a few minutes talking with me about development knows I love Go. My Github and Blog are practically a love letter to the language. Today I want to share with you something I’ve been working on for the past year, and I hope you will really get excited about it. Many applications require access to the file system to create, modify or delete files and folders. I’ve always felt a bit
はじめに Go Advent Calendar 2015 その3の5日目の記事です。 AWS SDK for Go(以下SDK) は ver 1.0.0 が11月にリリースされ12月4日時点でver 1.0.3がリリースされています。 この記事ではSDKの基本的な使い方と私が実際に行ったRoute53を対象にしたSDKの利用方法について書きます1。 基本的な使い方 パッケージの取得 まずはパッケージを取得する必要があるのでgo getコマンドで取得します。 go get github.com/aws/aws-sdk-go またcredentialsファイルの読み込みなどで使用するためgo-iniパッケージも入れます。 go get github.com/vaughan0/go-ini あとは通常通りimportして利用します。基本的には以下の3つと必要なサービス(github.com/aw
この記事は Go Advent Calendar 2015 5 日目の記事です。 はじめに Go にはジェネリクスがありませんが、任意の型に対して共通の処理を提供したいことがあります。 例えば ORM ライブラリで User テーブルと Blog テーブルを struct で表す場合を考えてみます。 type User struct { Id int64 Name string Email string } type Blog struct { Id int64 Title string Body string } この 2 つの struct に対して共通の処理、例えば id で検索して結果を返す FindById というメソッドを提供したいとします。 Go は静的型付き言語なので、複数の型を引数に取ったり、複数の型を返すといったメソッドを定義することはできません。 よって、それぞれの型
Go その2 Advent Calendar 2015 – Qiita 1日目のエントリ第一弾です。(第二弾: Echo – Go 言語 Web Framework の紹介) 当社では現在プロダクトの開発に Go言語 を利用しています。開発の中で得られた知見を徐々に公開していきます。 Go 言語で利用されるデータベース関連パッケージでは、O/R Mapper に位置づけられる gorm や gorp、 QueryBuilder の squirrel が広く知られています。 今回のエントリでは、おすすめの O/R Mapper dbr を紹介します。 gocraft/dbr – Github dbr は、現在 Star の数では gorm や gorp に比べ少ないですが、2015年9月に更新された V2.0 で機能が大幅に強化され、これから人気が高まるのではないかと予想しています。 dbr
This document discusses the concept of "simple" and "easy" as it relates to programming languages and Clojure in particular. It explores the differences between concepts that are simple versus complex, and easy versus hard. It provides examples of how Clojure aims to make programming simple by avoiding unnecessary complexity through choices like immutable data and avoiding side effects.
Go の言語仕様はシンプルで他の言語に比べてはまりどころが少なくて学習コストが小さめな言語のように思います。しかし、それでもはまるところがないわけではないので、自分がはまって時間を無駄にしてしまったことを書き留めておきます。 念の為誤解のないように追記しておくと、この文書の目的は Go を批判することではなく Go が Go であるがゆえに C++/Java/Python など利用者が Go を使い始めるときに困惑あるいは誤解するであろうポイントをまとめておくことで初めて Go を触る人がスムーズに Go を使い始められるようにすることです。私個人は Go はバランスがとれた良い言語でだと思いますし、気に入っています。 目次 interface と nil (Go の interface は単なる参照ではない) 文献 メソッド内でレシーバ(this, self)が nil でないことをチェ
はじめに タイトルの通りvimで作るGoの開発環境が便利なのでまとめたものです。 特にコードリーディングに便利な設定を紹介します。 参考 本稿を書くに当たって参考になった記事です。 日付が新しい順に並べていますので下の方は古い記述を含んでいます。 vim-go-extra を公開致します。 http://vim-jp.org/blog/2014/09/02/vim-go-extra.html Go 1.2.1 の環境構築 Homebrew + Vim 編 (2014.03) http://qiita.com/methane/items/4905f40e4772afec3e60 Big Sky :: Vimを使ったGo言語開発手法 http://mattn.kaoriya.net/software/vim/20130531000559.htm goのvimコマンド「Fmt」が、実はquick
Go のプロジェクトのディレクトリ構成などについて プロジェクト構成 プロジェクトディレクトリをgo_workとする。 go_work ├── bin -> go install 時にバイナリが格納される ├── pkg -> 依存パッケージのオブジェクトファイル格納場所 └── src -> ソースコード格納場所 上記3つのディレクトリがあることが前提。 環境変数$GOPATHにプロジェクトディレクトリを指定することで、依存パッケージの解決が自動的に行われる。 % cd go_work % export GOPATH=`pwd` パッケージについて Go のパッケージは、Ruby で言うところの gem にあたる。 パッケージは自分で作ったり、Git などでリポジトリが公開されていれば、それをgo get コマンドでコピーして利用できる。 パッケージの作成 gosample というパッケ
isucon予選中に、SQLを出力したくなったのだけど、ふとgithub.com/shogo82148/go-sql-proxyを使ってみようとしてとりあえず簡単に使う方法が書いてなくて少し使い方を調べるのに苦労したので、isuconで時間のロスなく使えるようにそのwrapperを書きました。 package main import ( database/sql "github.com/go-sql-driver/mysql" # load driver before load go-sql-tracer _ "github.com/walf443/go-sql-tracer" ) func main() { db, err := sql.Open('mysql:trace', dsn) } ポイントは、 元々使っていたドライバ名に":trace"とつけること go-sql-driver/
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く