function replace_if_necessary() {
  version=$1
  platform=$2
  blobname=$(basename $(ls ../golang-${version}/*${platform}*))
  if ! bash -c "bosh blobs | grep -q ${blobname}"; then
    existing_blob=$(bosh blobs | awk '{print $1}' | grep "go${version}.*${platform}")
    if [ -n "${existing_blob}" ]; then
      bosh remove-blob ${existing_blob}
    fi
    bosh add-blob --sha2 ../golang-${version}/${blobname} ${blobname}
    bosh upload-blobs
  fi
}


function replace_if_necessary() {
  version=$1
  platform=$2
  blobname=$(basename $(ls ../golang-${version}/*${platform}*))
  if ! bosh blobs | grep -q ${blobname}; then
    existing_blob=$(bosh blobs | awk '{print $1}' | grep "go${version}.*${platform}" || true)
    if [ -n "${existing_blob}" ]; then
      bosh remove-blob ${existing_blob}
    fi
    bosh add-blob --sha2 ../golang-${version}/${blobname} ${blobname}
    bosh upload-blobs
  fi
}


Fix case when blob does not exist
Fix case when blob does not exist

[#160069129](https://www.pivotaltracker.com/story/show/160069129)

Co-authored-by: Danny Berger <8efccf38e9d8f361e1973ad644e1b1e50ad8ecfe@pivotal.io>
