Tips for writing clear, performant, and idiomatic Go code
![Getting to Go: The Journey of Go's Garbage Collector - The Go Programming Language](https://cdn-ak-scissors.b.st-hatena.com/image/square/61955b2029cca886435bd7bb93b949e8f18ae48d/height=288;version=1;width=512/https%3A%2F%2Fgo.dev%2Fdoc%2Fgopher%2Frunningsquare.jpg)
This post is not available in your language. Here are some other options: English Go memory ballast: How I learned to stop worrying and love the heap I’m a big fan of small code changes that can have large impact. This may seem like an obvious thing to state, but let me explain: These type of changes often involve diving into and understanding things one is not familiar with. Even with the most we
How we tracked down (what seemed like) a memory leak in one of our Go microservices Detectify is driving the future of internet security with appsec solutions powered by automation and crowdsourcing of web vulnerabilities. Detectify is a cloud-native security solution built upon microservices and here comes a blog post from the tech team’s adventures. The developer team at Detectify has been worki
intro 先日 GoのSliceもヤバイ - Qiita こんな記事をみて、別の挙動だけどスライスの内部を理解しきれていなかった頃のことを思い出した。 結構前に謎に思っていた挙動についての話。 以前この挙動を解説しようと思って、前提として書いたスライスの内部構造の記事が、 Go のスライスの内部実装 だったのですが、そっちを書き終わって満足してしまい、本題を忘れていました。 この挙動は、先のブログで説明した内容がわかっていないと、なかなか理解できないかも。わかってしまえば簡単ですが。 やりたいのは、関数側でスライスを操作したときの呼び出し側での結果。 順を追ってみてみます。 配列を関数内で変更する 関数は値渡しで、配列はそれ自体が値なので、まるっとコピーされます。 以下の例は、戻り値で返さないと、呼出側は変化しません。 package main import ( "log" ) func
History 14/05/09: Merge2 を修正しました。http://twitter.com/jbking/status/464659353945911297 Intro Go のスライスは、いわゆる LL 系の言語が持つ可変長配列の実装と似ています。 よって LL のような手軽な扱いをすることもできますが、その内部実装を知ることでより効率の良いメモリハンドリングができ、パフォーマンスを改善や、メモリーリークの防止などに繋がる可能性があります。 この辺は SWrap というライブラリを作りながら勉強したので、今回は、この Go のスライスの内部実装を解説します。 Go の配列 スライスを知るためには、まず配列について知っておく必要があります。 Go の配列は固定長のため、以下のように長さを指定して宣言します。 var arr [4]int func main() { arr =
間接参照(かんせつさんしょう、英: indirectionもしくは英: indirection reference)とは、コンピュータのプログラミング、特にプログラミング言語において、ある値 (value) を、値そのものによってではなく、名前 (name) や参照 (reference) などにより間接的に指し示すこと、およびその参照自身のことや、それを参照して操作することである。 英語の direct は「指示する」「直接の」という意味があり、indirect は「間接的な」という意味がある。また、indirection は「遠回り」「回り道」という意味がある。通例「参照」という日本語は英語の reference に対応するが、プログラミングの用語および規格の文脈では indirection の一語だけでも「間接参照」を意味する。また、デリファレンス(dereference)とは、参照
Go言語のポインタ C言語でおなじみのポインタですが、Go言語にもポインタがあります。 宣言する方法もC言語と同じで、たとえばint型変数のポインタは、「*int」と記述します。変数のアドレスを取得するときも、C言語と同様に「&」をつけ、アドレスから変数の中身へアクセスする時は「*」を使います。 ポインタの使用例は次の通り。 package main import ( "fmt" ) func main() { // int型のポインタ変数 var pointer *int // int型変数 var n int = 100 // &(アドレス演算子)を使って、nのアドレスを代入 pointer = &n fmt.Println("nのアドレス:", &n) fmt.Println("pointerの値:", pointer) fmt.Println("nの値:", n) // *(間接参
Introduction The Go memory model specifies the conditions under which reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine. Advice Programs that modify data being simultaneously accessed by multiple goroutines must serialize such access. To serialize access, protect the data with channel operations or other synchr
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く