#!/bin/bash

##
# Add header to files
##
HEADER=$(cat header.txt)
for i in $(find . -name \*.go); do
    if [ "${i:2:7}" = "restapi" ] || [ "${i:2:6}" = "models" ] || [ "${i:2:3}" = "cmd" ] && [ "$(basename $i)" != "configure_weaviate.go" ]; then
        DOCUMENT=$(cat $i)
        echo "$HEADER $DOCUMENT" > $i
    fi
done

##
# Remove unused text in files
##
for i in $(find . -name \*.go); do
    sed -i -e 's/\/\/ Code generated by go-swagger; DO NOT EDIT./ /g' $i
    sed -i -e 's/\/\/ This file was generated by the swagger tool./ /g' $i
    sed -i -e 's/\/\/ Editing this file might prove futile when you re-run the swagger generate command/ /g' $i
    sed -i -e 's/\/\/ Editing this file might prove futile when you re-run the swagger generate command/ /g' $i
done

##
# Remove temp file
##
find . -type f -name '*.go-e' -delete
#!/bin/bash

##
# Add header to files
##
HEADER=$(cat header.txt)
for i in $(find . -name \*.go); do
    if [ "${i:2:7}" = "restapi" ] || [ "${i:2:6}" = "models" ] || [ "${i:2:3}" = "cmd" ] && [ "$(basename $i)" != "configure_weaviate.go" ]; then
        DOCUMENT=$(cat $i)
        echo "$HEADER $DOCUMENT" > $i
    fi
done

##
# Remove unused text in files
##
for i in $(find . -name \*.go); do
    sed -i -e 's/\/\/ Code generated by go-swagger; DO NOT EDIT./ /g' $i
    sed -i -e 's/\/\/ This file was generated by the swagger tool./ /g' $i
    sed -i -e 's/\/\/ Editing this file might prove futile when you re-run the swagger generate command/ /g' $i
    sed -i -e 's/\/\/ Editing this file might prove futile when you re-run the swagger generate command/ /g' $i
done

##
# Remove temp file
##
find . -type f -name '*.go-e' -delete

##
# run go fmt
##
go fmt ./...
Add gofmt to header file
gh-174: Add gofmt to header file
