All Projects → masibw → goone

masibw / goone

Licence: MIT license
goone finds N+1 query in go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to goone

Ppipe
A simple and lightweight Rust library for making iterator pipelines concurrent
Stars: ✭ 13 (-68.29%)
Mutual labels:  loop
Dottask
Simple and easy go task framework, support loop & cron & queue
Stars: ✭ 124 (+202.44%)
Mutual labels:  loop
Ructe
Rust Compiled Templates with static-file handling
Stars: ✭ 206 (+402.44%)
Mutual labels:  loop
Swiftysound
SwiftySound is a simple library that lets you play sounds with a single line of code.
Stars: ✭ 995 (+2326.83%)
Mutual labels:  loop
Service
Service encapsulates an object which executes a bit of code in a loop that can be started or stopped and query whether it is running or not.
Stars: ✭ 86 (+109.76%)
Mutual labels:  loop
Processingstuff
Various pretty-ish Processing sketches by Blokatt. About 50% shaders.
Stars: ✭ 153 (+273.17%)
Mutual labels:  loop
Fast Cgi Client
A PHP fast CGI client for sending requests (a)synchronously to PHP-FPM
Stars: ✭ 478 (+1065.85%)
Mutual labels:  loop
animate
👾 Create and manage animation functions with AnimationFrame API.
Stars: ✭ 11 (-73.17%)
Mutual labels:  loop
Akvideoimageview
UIImageView subclass that allows you to display a looped video and dynamically switch it.
Stars: ✭ 123 (+200%)
Mutual labels:  loop
Patches
Patches is a visual programming editor for building WebVR and WebGL experiences.
Stars: ✭ 164 (+300%)
Mutual labels:  loop
Bentools Etl
PHP ETL (Extract / Transform / Load) library with SOLID principles + almost no dependency.
Stars: ✭ 45 (+9.76%)
Mutual labels:  loop
Infinite Uicollectionview
Make a UICollectionView infinitely scrolling by looping through content
Stars: ✭ 82 (+100%)
Mutual labels:  loop
Pyicp Slam
Full-python LiDAR SLAM using ICP and Scan Context
Stars: ✭ 155 (+278.05%)
Mutual labels:  loop
Superboucle
Loop application synced with jack transport
Stars: ✭ 31 (-24.39%)
Mutual labels:  loop
MatlabProgressBar
This MATLAB class provides a smart progress bar like tqdm in the command window and is optimized for progress information in simple iterations or large frameworks with full support of parallel parfor loops provided by the MATLAB Parallel Computing Toolbox.
Stars: ✭ 44 (+7.32%)
Mutual labels:  loop
React Text Loop
Animate words in your headings
Stars: ✭ 595 (+1351.22%)
Mutual labels:  loop
Docxtemplater
Generate docx pptx and xlsx (Microsoft Word, Powerpoint, Excel documents) from templates, from Node.js, the Browser and the command line / Demo: https://www.docxtemplater.com/demo
Stars: ✭ 1,990 (+4753.66%)
Mutual labels:  loop
TimerInterrupt
This library enables you to use Interrupt from Hardware Timers on an Arduino, such as Nano, UNO, Mega, etc. It now supports 16 ISR-based timers, while consuming only 1 hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behavin…
Stars: ✭ 76 (+85.37%)
Mutual labels:  loop
ViewWorld
自定义View合集,展示各种自定义View/控件。项目包含了自定义Banner轮播图控件,自定义验证码输入框,自定义TabLayout等控件,持续更新中😉😉😉
Stars: ✭ 94 (+129.27%)
Mutual labels:  loop
Shell Scripting Tutorial
A complete begineers guide to learn shell scripting from scratch which includes Videos, Practice scenarios and project idea.
Stars: ✭ 159 (+287.8%)
Mutual labels:  loop

test_and_lint

goone

goone finds N+1(strictly speaking call SQL in a for loop) query in go

Example

package main

import (
	"database/sql"
	"fmt"
	"log"

	_ "github.com/go-sql-driver/mysql"
)


type Person struct {
	Name string
	JobID int
}

type Job struct {
	JobID int
	Name string
}

func main(){

	cnn, _ := sql.Open("mysql", "user:password@tcp(host:port)/dbname")

	rows, _ := cnn.Query("SELECT name, job_id FROM persons")

	defer rows.Close()

	for rows.Next() {
		var person Person
		if err := rows.Scan(&person.Name,&person.JobID); err != nil {
			log.Fatal(err)
		}

		var job Job

        // This is N+1 query
		if err := cnn.QueryRow("SELECT job_id, name FROM Jobs WHERE job_id = ?",person.JobID).Scan(&job.JobID,&job.Name); err != nil { 
			log.Fatal(err)
		}
		fmt.Println(person.Name,job.Name)
	}

}

output

./hoge.go:38:13: this query is called in a loop

Install

go get github.com/masibw/goone/cmd/goone

Usage

bash

go vet -vettool=`which goone` ./...

fish

go vet -vettool=(which goone) ./...

CI

Github Actions

- name: install goone
    run: go get -u github.com/masibw/goone/cmd/goone
- name: run goone
    run: go vet -vettool=`which goone` -goone.configPath="$PWD/goone.yml" ./...

Library Support

  • sql
  • sqlx
  • gorp
  • gorm

You can add types to detect sql query.

Config

You can add any types that you want to detect as sql query. You can also detect the case where an interface is in between by writing below. example project

package:
  - pkgName: 'github.com/masibw/go_todo/cmd/go_todo/infrastructure/api/handler'
    typeNames:
      - typeName: '*todoHandler'

goone searches for goone.yml in directories up to the root from the file directory which analyzing currently. (not the working directory(command executed))

You can use the -goone.configPath flag at runtime to indicate config by an absolute path.

Example

If goone.yml exists in the directory where the command was executed

go vet -vettool=`which goone` -goone.configPath="$PWD/goone.yml" ./...

Contribute

You're welcome to build an Issue or create a PR and be proactive!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].