No description
  • Go 57.5%
  • HTML 42.2%
  • Makefile 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Fernandez Ludovic c99c5cf5c2 chore: update CI
2026-04-01 10:47:20 +02:00
.github/workflows chore: update CI 2026-04-01 10:47:20 +02:00
_output_example README: add output example 2015-05-20 21:48:43 +02:00
job git grep -l github.com/mibk/dupl | xargs sed -i'' -e 's/github.com\/mibk\/dupl/github.com\/golangci\/dupl/g'; git grep -l github.com/mibk/dupl | xargs goimports -w 2025-03-04 05:42:40 +01:00
lib fix: limit number of children 2025-03-08 03:42:27 +01:00
printer Improve HTML output styling 2026-04-01 10:43:52 +02:00
suffixtree Fix typos 2026-04-01 10:40:22 +02:00
syntax Fix typos 2026-04-01 10:40:22 +02:00
.gitignore chore: add gitignore 2025-03-04 05:52:40 +01:00
.golangci.yml chore: update CI 2026-04-01 10:47:20 +02:00
go.mod chore: use as a lib 2025-03-04 05:52:18 +01:00
LICENSE add LICENSE 2015-05-20 17:48:39 +02:00
main.go Change default threshold from 15 to 100 2026-04-01 10:43:42 +02:00
Makefile chore: use GitHub Action 2025-03-04 05:53:05 +01:00
README.md Change default threshold from 15 to 100 2026-04-01 10:43:42 +02:00

dupl

dupl is a tool written in Go for finding code clones. It can find clones only in the Go source files. The method uses a suffix tree for serialized ASTs. It ignores values of AST nodes. It just operates with their types (e.g. if a == 13 {} and if x == 100 {} are considered the same provided it exceeds the minimal token sequence size).

Due to the used method dupl can report so-called "false positives" on the output. These are the ones we do not consider clones (whether they are too small, or the values of the matched tokens are completely different).

Installation

go install github.com/mibk/dupl@latest

Usage

Usage: dupl [flags] [paths]

Paths:
  If the given path is a file, dupl will use it regardless of
  the file extension. If it is a directory, it will recursively
  search for *.go files in that directory.

  If no path is given, dupl will recursively search for *.go
  files in the current directory.

Flags:
  -files
        read file names from stdin one at each line
  -html
        output the results as HTML, including duplicate code fragments
  -plumbing
        plumbing (easy-to-parse) output for consumption by scripts or tools
  -t, -threshold size
        minimum token sequence size as a clone (default 100)
  -vendor
        check files in vendor directory
  -v, -verbose
        explain what is being done

Examples:
  dupl -t 200
        Search clones in the current directory of size at least
        200 tokens.
  dupl $(find app/ -name '*_test.go')
        Search for clones in tests in the app directory.
  find app/ -name '*_test.go' |dupl -files
        The same as above.

Example

The reduced output of this command with the following parameters for the Docker source code looks like this. The reduced output of this command with the following parameters for the Docker source code looks like this.

$ dupl -t 200 -html >docker.html