<commit_before># Copyright 2018 Datawire. All rights reserved.
#
# Makefile snippet to build Go programs using Go workspaces
# ("GOPATH").  Go workspaces are scheduled for deprecation in Go 1.13,
# which is scheduled for August 2019.
#
## Inputs ##
#  - Symlink: ./.go-workspace/src/EXAMPLE.COM/YOU/YOURREPO -> (git topdir)
#  - Variable: go.DISABLE_GO_TEST ?=
## Outputs ##
#  - Variable: go.module = EXAMPLE.COM/YOU/YOURREPO
#  - Variable: go.bins = List of "main" Go packages
#  - Variable: NAME ?= $(notdir $(go.module))
#  - Target: vendor/ (if `./glade.yaml` is present)
#  - .PHONY Target: go-get
#  - .PHONY Target: go-build
#  - .PHONY Target: check-go-fmt
#  - .PHONY Target: go-vet
#  - .PHONY Target: go-fmt
#  - .PHONY Target: go-test
## common.mk targets ##
#  - build
#  - lint
#  - check
#  - format
#  - clobber
ifeq ($(words $(filter $(abspath $(lastword $(MAKEFILE_LIST))),$(abspath $(MAKEFILE_LIST)))),1)
ifneq ($(go.module),)
$(error Only include one of go-mod.mk or go-workspace.mk)
endif
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk

#

# 0. configure the `go` command

export GO111MODULE = off
export GOPATH = $(CURDIR)/.go-workspace

# .NOTPARALLEL is important, as having multiple `go install`s going at
# once can corrupt `$(GOPATH)/pkg`.  Setting .NOTPARALLEL is simpler
# than mucking with multi-target pattern rules.
.NOTPARALLEL:

_go-clobber:
	find .go-workspace -exec chmod +w {} +
	rm -rf .go-workspace
	mkdir -p $(dir .go-workspace/src/$(go.module))
	ln -s $(call joinlist,/,$(patsubst %,..,$(subst /, ,$(dir .go-workspace/src/$(go.module))))) .go-workspace/src/$(go.module)
.PHONY: _go-clobber
clobber: _go-clobber

#

# 1. Set go.module

go.module := $(patsubst src/%,%,$(shell cd .go-workspace && find src \( -name '.*' -prune \) -o -type l -print))
ifneq ($(words $(go.module)),1)
  # Print a helpful message
  ifeq ($(wildcard .go-workspace/),)
    $(info go-worksapce.mk: Directory `./go-workspace/` does not exist.)
    ifeq ($(wildcard go.mod),)
      $(info go-workspace.mk: Initialize it with:)
      $(info go-workspace.mk:     $$ mkdir -p .go-workspace/src/github.com/YOU)
      $(info go-workspace.mk:     $$ ln -srT . .go-workspace/src/github.com/YOU/REPONAME)
    else<commit_msg>(teleproxy) go-workspace.mk: Enable parallel build, drop ".NOTPARALLEL:"<commit_after># Copyright 2018 Datawire. All rights reserved.
#
# Makefile snippet to build Go programs using Go workspaces
# ("GOPATH").  Go workspaces are scheduled for deprecation in Go 1.13,
# which is scheduled for August 2019.
#
## Inputs ##
#  - Symlink: ./.go-workspace/src/EXAMPLE.COM/YOU/YOURREPO -> (git topdir)
#  - Variable: go.DISABLE_GO_TEST ?=
## Outputs ##
#  - Variable: go.module = EXAMPLE.COM/YOU/YOURREPO
#  - Variable: go.bins = List of "main" Go packages
#  - Variable: NAME ?= $(notdir $(go.module))
#  - Target: vendor/ (if `./glade.yaml` is present)
#  - .PHONY Target: go-get
#  - .PHONY Target: go-build
#  - .PHONY Target: check-go-fmt
#  - .PHONY Target: go-vet
#  - .PHONY Target: go-fmt
#  - .PHONY Target: go-test
## common.mk targets ##
#  - build
#  - lint
#  - check
#  - format
#  - clobber
ifeq ($(words $(filter $(abspath $(lastword $(MAKEFILE_LIST))),$(abspath $(MAKEFILE_LIST)))),1)
ifneq ($(go.module),)
$(error Only include one of go-mod.mk or go-workspace.mk)
endif
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk

#

# 0. configure the `go` command

export GO111MODULE = off
export GOPATH = $(CURDIR)/.go-workspace

_go-clobber:
	find .go-workspace -exec chmod +w {} +
	rm -rf .go-workspace
	mkdir -p $(dir .go-workspace/src/$(go.module))
	ln -s $(call joinlist,/,$(patsubst %,..,$(subst /, ,$(dir .go-workspace/src/$(go.module))))) .go-workspace/src/$(go.module)
.PHONY: _go-clobber
clobber: _go-clobber

#

# 1. Set go.module

go.module := $(patsubst src/%,%,$(shell cd .go-workspace && find src \( -name '.*' -prune \) -o -type l -print))
ifneq ($(words $(go.module)),1)
  # Print a helpful message
  ifeq ($(wildcard .go-workspace/),)
    $(info go-worksapce.mk: Directory `./go-workspace/` does not exist.)
    ifeq ($(wildcard go.mod),)
      $(info go-workspace.mk: Initialize it with:)
      $(info go-workspace.mk:     $$ mkdir -p .go-workspace/src/github.com/YOU)
      $(info go-workspace.mk:     $$ ln -srT . .go-workspace/src/github.com/YOU/REPONAME)
    else
{'fraction_non_alphanumeric': 0.18158744808491, 'fraction_numerical': 0.008306414397784956, 'mean_word_length': 3.304865938430983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '569518', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1646, 'n_words': 420}