一年前のGoCon Kyotoの発表資料をどこにも載せていなかったので、書いておきます。 Golangを使ったDB用負荷テストツールの開発 by @winebarrel github.com
This is the chapter 23 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – Channel Previous Tutorial – Iota Now let’s check out the current tutorial. Below is the table of contents for current tutorial. Overview Goroutines can be thought of as a lightweight thread that has a separate independent ex
はじめに 今回この記事を書こうと思った背景として、とある技術記事でLoggerの実装方法について盛り上がってるものを見つけて、その部分の知見が弱い事を再認識させられた一件がありました。 また、一年弱ほど長期インターンでGo言語を沢山書いてきた中で、シンプルな文法で様々なDesignPatternを表現できるGo言語も面白さを皆さんに知っていただきたいなという想いも込めました。 それではGopher君の世界に踏み入れていきましょう。 Dependecy Injection Dependency Injection(DI)は、依存関係の逆転(Dependency Inversion)の原則を実現するためのデザインパターンです。DIを使用すると、高レベルのモジュールが低レベルのモジュールに直接依存するのではなく、抽象化を介して間接的に依存するようになります。これにより、モジュール間の結合度を低く
はじめに クリーンアーキテクチャは、ソフトウェア設計の分野で非常に重要な概念です。 しかし、その理解は容易ではなく、明確な正解が存在するわけではありません。 多くの人が異なる解釈を持ち、他の設計思想と混在していることもあります。 この記事では、自分なりの視点からクリーンアーキテクチャを解釈し、その整理した内容を共有します。 このアーキテクチャの目的は、システムの各層を独立させ、変更に強く、テストしやすい設計を実現することです。 この記事では、クリーンアーキテクチャの基本概念、Golangでの実装方法、およびディレクトリ構成について詳しく説明します。 なお、この記事では個人的な見解を述べており、必ずしも正解を書いているわけではありません。もし誤りがあれば、ぜひご指摘いただけると幸いです。 クリーンアーキテクチャの基本概念 クリーンアーキテクチャの元となったのは、ロバート・C・マーチン(通称「
Profile id: Songmu (ソンムー) Masayuki Matsuki / 松木雅幸 株式会社ヘンリー VP of Engineering おそらくはそれさえも平凡な日々 http://www.songmu.jp/riji/ https://metacpan.org/author/SONGMU 好きな言語は、PerlとGoと中国語 3 Times ISUCON Winner Using Perl 入門監視 付録C 執筆 「みんなのGo言語」共著者
Hi, this is Charu from Classmethod. In this blog we will cover the basics, including setting up your Go environment, writing simple programs, understanding Go's type system, and exploring Go routines for concurrency. Let's get started! Setting Up Your Environment The Go programming language can be installed from the official Go website. Follow the installation instructions for your operating syste
Go is great for building command-line applications. We built one: Dolt, the world's first version-controlled SQL database. We wrote our own command line parser for handling all of Dolt's subcommands and arguments, but maybe we shouldn't have. There are lots of great ones out there that if we might have used instead if we were starting the project today: spf13/cobra has great support for code gener
One Billion Row Challenge in Golang - From 95s to 1.96s Renato Pereira Mar 18, 2024 Introduction The One Billion Row Challenge (1BRC) is quite simple: the task is developing a program capable of read a file with 1 billion lines, aggregating the information contained in each line, and print a report with the result. Each line within the file contains a weather station name and a temperature reading
完成物 ER図 画面遷移図 figma, 原寸画像 AWS構成図 ※備考※ GitHub Actions CIは構築済みです。 GitHub Actions CD, apiのprivate subnet化にも取り組んでいます。 EC2インタンスは通常時停止です。 技術選定理由 プログラミング、IT業界ともに未経験で着手し独学で作りました。 Go 比較対象:JAVA、Ruby、Python、PHP コンパイラ言語であり実行速度が高速である 静的型付けであり、コンパイル前にバグを発見しやすい 静的型付けかつ記述自由度が低いことから、以下2点を利点と考えた 開発を中長期まで続けた際にも、加筆・改修しやすい 他人のコードを読んだ際に学びやすい Javaも多少書いてみたが、簡素にかけるGoの方がしっくりきた SHOWROOM、IRIAM、Twitch、AbemaTVといった動画配信サービスにも採用さ
1. はじめに 「Active Recordみたいな使用感のGolang製のORMが無いかなー?」と思って色々なORMを触っている中で、おすすめのORM「ent.」見つけたので備忘録+布教も兼ねて本記事を残そうと思います。 --- 2024/01/07 追記 --- 本記事で割愛していたVisualize the Schemaに関する記事を投稿しました。 スキーマの可視化に興味のある方は覗いてみてください。 2. ent.って何? Metaが開発しているGolang製のORMです。 近年、githubのスターも伸びており、公式のドキュメントも充実しているので安心感があります。 また、RailsやDjangoでの開発経験がある方には、以下の特徴があるため非常に馴染みやすいと思っています。 定義したschemaからテーブルが作れる Atlasを利用することで、マイグレーションのバージョンを管理
はじめまして、グッドパッチでサーバーサイドエンジニアをやってる荒木です。 この記事は Goodpatch Advent Calendar 2023 の 24日目の記事になります。 はじめに 現在golangで開発に使ってるフレームワークはginですが、そろそろ切り替えも検討したいので調べてみました。 対象になるフレームワーク Webアプリ開発に利用できるもので、スターの多いものをピックアップしています。 gin-gonic/gin (⭐️73.2k) 私も業務で利用していますが、一番最初に候補に上がるかと思います。 利用していてポイントとなる部分。 高速:他のフレームワークはginよりベンチマークが高かったりしますが、実用性として十分な速度です。 ミドルウェアサポート:ミドルウェアを使うことで認証系とかはシンプルに作りやすいです。 JSONバリデーション:普通に利用できます、フィールドが空
この記事は、Azure Advent Calendar 2023 の 10 日目の記事です。🎄 はじめに Azure OpenAI Service では、 text-embedding-ada-002 というモデルを使って、文章を 1536 次元のベクトルに Embedding できます。 また、PostgreSQL では、 pgvector という拡張機能を使って、ベクトルを保存・検索機能を導入できます。 今回はこれらを組み合わせて、Azure OpenAI で Embedding したベクトルを Golang のアプリケーションから PostgreSQL に保存し、類似度検索する方法を紹介します。 pgvector とは pgvector は、PostgreSQL にベクトルデータを保存・検索する機能を追加する拡張機能です。 ベクトルデータを保存するためのデータ型と、ベクトルデータを
The Authentication Session of a web app is the heart of its defense against malicious threats. Hence, it is among the first points of recon for a security tester. This article will discuss the authentication sessions of a web app in the “Go” programming language (Golang). It will also discuss the vulnerabilities and design flaws in authentication sessions, the difference between Session-Based and
Hello! If you have been following our articles, you may remember reading that Krater was being developed with Rust using Tauri. However, this is no longer the case because a few months ago we made the decision to migrate the entire project to Wails (Golang). In this article, we will discuss our experience and why we made such a risky decision to migrate an entire application from one language to a
Amazon Verified Permissions とは 従来の認可処理 Cedar 言語の使い方 基本的な記述方法 RBAC の例 ABAC の例 golang で動かしてみる 1. ポリシーストアを AWS コンソールから作成する 3. サンプルアプリケーションの実装 最後に こんにちは、2023年5月にバックエンドエンジニアとしてジョインした yamanoi です。 最近は Cloudflare スタックに注目しており、新機能を触ったりアップデートを眺めたりしています。 今回は先日 GA (一般利用可能)になった AWS のサービス Amazon Verified Permissions を、 golang で実装した簡単なサンプルを交えて紹介したいと思います。 Amazon Verified Permissions とは Amazon Verified Permissions
はじめに オライリーでポートスキャナ自作ではじめるペネトレーションテストという本が発売されました。 2章ではScapyを利用して実際にパケットを作成して、nmapのようなポートスキャナ自作します。 パケットのカプセル化などNWの仕組みから丁寧に解説されていてとても良書だと思います。 ただ筆者はPythonよりGolang派なので2章のプログラムをGolangに書き換えてみました。 ※オリジナルはこちら gopacket入門 gopacketはGolangでパケットを読み込んだり作ったりするためのライブラリです。 プログラムを作る前に必要なパッケージをインストールしておきます。 ubuntu 22.04で動作確認をしています。
10 October 2023: Updated to clarify escaping: both paths and patterns are unescaped segment by segment, not as a whole. We found during implementation that this gives the behavior we would expect. 7 August 2023: updated with two changes: added Request.SetPathValue GET also matches HEAD We propose to expand the standard HTTP mux's capabilities by adding two features: distinguishing requests based o
This is a discussion intended to lead to a formal proposal. This was written with input from @mvdan, @johanbrandhorst, @rogpeppe, @chrishines, @rsc. Background The widely-used "encoding/json" package is over a decade old and has served the Go community well. Over time, we have learned much about what works well and what does not. Its ability to marshal from and unmarshal into native Go types, the
50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs 50 Shades of Go in Other Languages Chinese Translation: blog post, segmentfault (by wuYin) - needs updates Another Chinese Translation: blog post (by Shadowwind LEY) - needs updates Russian Translation: blog post (by Ilia Ozhereliev, Mail.Ru Group Blog) - needs updates Overview Go is a simple and fun language, but, like any o
This post narrates our journey to developing advanced functions in our VSCode extension for Lama2, a plain-text API manager built at Hexmos. We will see how our thinking and implementation evolved through three stages over a period of a year. The Genesis of Lama2 🦙 Lama2 is a plain-text oriented API manager optimized for team collaboration via Git. At Hexmos, we store all our APIs in a Git reposi
# APITo see the full list of supported methods, see SelectQueryopen in new window. db.NewSelect(). With("cte_name", subquery). Model(&strct). Model(&slice). Column("col1", "col2"). // quotes column names ColumnExpr("col1, col2"). // arbitrary unsafe expression ColumnExpr("count(*)"). ColumnExpr("count(?)", bun.Ident("id")). ColumnExpr("(?) AS alias", subquery). ExcludeColumn("col1"). // all column
概要 Golangで書いた簡単なRest API のテストコードを書いてみた記事です。 構成 handler HTTPリクエストを処理するハンドラー関数。 usecase ビジネスロジック、各種操作の実行、ハンドラーとリポジトリの橋渡し。 repository DBと接続し、CRUD操作を実施。 ディレクトリ構成(抜粋) 詳細 微妙なところはあるかもです。utilとかの置き場所は今考えると微妙です( internal のほうが良いかも)。 . ├── go.mod ├── go.sum ├── internal #外部に公開しない、プロジェクト内のみで使うロジック。リポジトリの実装もここ。 │ ├── config │ └── repositories #リポジトリ層(DB操作) │ ├── fixtures │ │ └── stocks.yaml │ ├── stock_category
Project Status Update - Jul 17, 2023We were going to wait until the transition was complete to make an announcement, but it seems that the cat is out of the bag… We are excited to confirm that the Gorilla web toolkit project has a new group of Core Maintainers! We are all thrilled by the positive response from the community so far. Here is a list of what we are currently working on to complete the
Go × PostgreSQL × SQLBoiler (ORM) × golang-migrate (マイグレーション) の開発環境を構築するGoPostgreSQLDockerSQLBoilergolang-migration 毎回環境を作るときに何かしらド忘れしてしまい手こずってしまうので忘れないようにメモ。 はじめに 下記の知識や経験があることを前提にしてます Go言語の基礎を理解している Dockerと docker-compose の基礎を理解している バックエンド開発やデータベースの基礎を理解している ORMの使い方や各種コマンドの詳しい説明はしません パスなどはご自身のプロジェクトの構成に合わせて適宜変更してください 作ったもののサンプルです。 開発環境 Go1.20 PostgreSQL 15 Docker docker-compose 使用するツール SQLBoler
この抜粋の内容は次のとおりです。 Cloud Spanner Emulator の導入 Spanner で CRUD gRPC API の実装: connect-go さらに詳しく知りたい方は読み続けてください。 2023年7月2回目です。 普段、ぼくたちの Database の第一の選択肢は、Cloud SQL です。 ですが、今後、可用性が求められるフェーズに対応するために、Cloud Spanner での開発について調査します。 Cloud Spanner は、今のサービス群で使うには高価です。最小サイズが Processing Unit になったとは言え。 一方で、強整合性を持ちながらグローバルな負荷分散が可能で、これを CockroachDB などで運用すると考えると妥当な価格であることも認識しています。 Cloud Spanner Emulator の導入 gRPC リクエスト
# モジュール初期化 $ go mod init example.com/hello # echo $ go get github.com/labstack/echo/v4 version: '3' services: app: build: . ports: - '3030:3000' # ローカルの3030番ポートでコンテナの3000番ポートに接続 volumes: - .:/app # ローカルとコンテナのディレクトリをマウント(同期) - go_path:/go # パッケージやバイナリファイルのインストール先($GOPATH)を永続化 volumes: go_path: FROM golang:1.18 # コンテナの作業ディレクトリにローカルのファイルをコピー WORKDIR /app COPY . /app # 必要なパッケージをインストール RUN go mod tidy
GolangとGPT APIを利用して、入力したトピックから自動的にwordpressにブログを投稿できるようにしてみるGoWordPressプログラミングAPIGPT-4 はじめに OpenAIからchatGPTという対話できるAIが世間を賑わせています。 これを利用して自動的にWordPressで記事を投稿してみようと思い、今勉強中のGolangを使って作ってみようと思いました。 GPT APIのドキュメントなどは、Pythonでのドキュメントがほとんどなので基本的にはPythonを利用するのが一般的かなと思います ちなみにGPT APIの利用方法などは私が個人で書いてるブログで紹介してます また、全量のコードについてはこちらに置いています。 参照 GPT APIリファレンス Wordpress APIリファレンス まずはプロンプトを考える 質問した回答を想定して、回答は日本語で質問は
はじめに Prometheus でアプリケーションの構築をしているとどうしてもこの値が取りたいのに... と思うことが多々ある。Pushgateway も選択肢として上げられるが今回は選択肢を増やしてほしいという意味でもExporterの実装方法について検討していきます。ExporterはPrometheusのpull モデルに適合し、監視対象のライフサイクルと一貫性があり、スケーラビリティと自動検出の利点を享受できるため、Pushgatewayよりも推奨される方法です。ただし、特定のユースケース(サービスレベルのバッチジョブなど)では、Pushgatewayの使用が適切な場合もあります。Pushgatewayを使う際には以下の問題点があるので注意が必要です。 複数のインスタンスを1つのPushgatewayで監視すると、単一障害点とボトルネックが発生する可能性がある。 Prometheu
今回やること 今回は、csvファイルを読み込む時に カラムの名称、数に関係なく構造体で取得できるように実装してみます。 ※ Generics機能を使うので、goのバージョンは1.18以上である必要があります。 実装の流れ 最終的なゴールは、抽象的な構造体(CsvAbstract)を作り、そこにcsvコンバート用のメソッド(ConvertCsv)を生やします。 呼び出し側は、自分の好きな構造体をCsvAbstractに当てはめて、ConvertCsvをコールするだけ。 CsvAbstractのDataプロパティを見て、先程当てはめた構造体のインスタンスが入っていれば完成。 今回csv関連で使用するパッケージは、github.com/jszwec/csvutilです。 抽象化した構造体とジェネリクス関数を定義 ジェネリクス機能を使うことで、「型が異なるだけで同じ処理をもつ複数の関数」を「1つの
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く