Errors running the first Go project on the local machine - go

I've installed the latest version of Go on my local machine, downloaded the source code from https://github.com/rrrkren/topshot-sales, and placed the project code in my GOPATH.
When I run it go run go/main.go in my command prompt, I get these errors
go\main.go:8:2: no required module provides package github.com/onflow/flow-go-sdk/client: go.mod file not found in current directory or any parent directory; see 'go help modules'
go\main.go:6:2: no required module provides package github.com/rrrkren/topshot-sales/topshot: go.mod file not found in current directory or any parent directory; see 'go help modules'
go\main.go:9:2: no required module provides package google.golang.org/grpc: go.mod file not found in current directory or any parent directory; see 'go help modules'
Even though the go.mod file is located in the current directory. I would like to be able to download this project and keep it on my local machine, so I can edit the source code whenever I want. How can I do that?

This is what worked for me.
Step 1. Delete any previous Go version if you are doubtful about having it configured properly.
Step 2. Install new Go version. Download the binary release (Go) from here Go Binary Download
Note: In order to delete and install the new Go version you can use these steps - Go Deletion and Installation, they worked for me. Also the version I am currently using is 1.16.3.
Step 3. After completing step 1 and step 2, run the following command in a terminal:
go env -w GO111MODULE=auto
This should do it.

You should not need a GOPATH environment variable with Go 1.16.
Only:
GO111MODULE=on (won't be needed in Go 1.17 or 1.18)
GOPROXY=https://proxy.golang.org,direct
GOROOT=C:\path\to\go
(GOROOT unless you have installed Go in its default folder: %USERPROFILE%\go)
I tried:
D:\git> git clone https://github.com/rrrkren/topshot-sales
Cloning into 'topshot-sales'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 25 (delta 9), reused 21 (delta 6), pack-reused 0
Receiving objects: 100% (25/25), 16.95 KiB | 5.65 MiB/s, done.
Resolving deltas: 100% (9/9), done.
D:\git> cd topshot-sales
D:\git\topshot-sales> go run main.go
go: downloading github.com/onflow/flow-go-sdk v0.10.0
...
go: downloading gopkg.in/yaml.v2 v2.2.5
panic: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 35.193.214.129:9000: i/o timeout"
goroutine 1 [running]:
main.handleErr(...)
D:/git/topshot-sales/main.go:14
main.main()
D:/git/topshot-sales/main.go:23 +0x805
exit status 2
No error about go.mod, only a runtime execution error.

If you're on macOS, run the following command first and then retry:
xcode-select --install
Reference: Why am I getting an “invalid active developer path” when attempting to use Git after upgrading to macOS Monterey?

Related

Heroku, providing a deb dependency to Go project through APT buildpack does not work out

I have a PDF conversion package in my Go project which relies upon "wkhtmltox" debian package. I install "wkhtmltopdf" (similar to "wkhtmltox") through APT buildpack before running a Go buildpack. The "wkhtmltopdf" has been tested locally, and in this case Go project builds perfectly. But when I do it in Heroku, it does not work out, and fails with the same error as would pop out in case no "wkhtmltox" nor "wkhtmltopdf" was installed. The successfully installed "wkhtmltopdf" :
remote: -----> Installing wkhtmltopdf_0.12.5-1build1_amd64.deb
The error :
remote: ../codon/tmp/cache/go-path/pkg/mod/github.com/adrg/go-wkhtmltopdf#v0.2.2/converter.go:7:10: fatal error: wkhtmltox/pdf.h: No such file or directory
remote: 7 | #include <wkhtmltox/pdf.h>
remote: | ^~~~~~~~~~~~~~~~~
remote: compilation terminated.
Is there someone with similar experience ? Is it possible that for Go the installed package is simply not available without some additional manipulations ?

Create-react-app build failing on heroku when using absolute paths

When using absolute paths in my CRA, the build step fails on heroku.
NODE_PATH=src/
Is in my .env.local file and also use this env var in my heroku settings.
I try to build my app on heroku using the "heroku-postbuild" script (which just runs "react-scripts build". I am using an express server to serve this build folder and to proxy requests to various API's.
this is the error I get:
remote: Running heroku-postbuild (yarn) remote: yarn run
v1.14.0 remote: $ react-scripts build remote: Creating
an optimized production build... remote: Failed to compile.
remote: remote: ./src/app/App.js remote: Cannot find
module: 'checklist/Checklist'. Make sure this package is installed.
remote: remote: You can install this package by running: yarn
add checklist/Checklist. remote: remote: remote: error Command failed
with exit code 1.
the Checklist.js file is located under: "src/checklist/Checklist.js"
Any idea what I need to do to make this work?
I had this issue and it seemed to be a result of my local file having a different casing than the one committed to git. i.e. if you have a file Checklist.js committed to git and are trying to import checklist from 'checlist/checklist.js', run git mv [...]/checklist.js [...]/Checklist.js.
See this issue comment for the original answer that got me here.
Just create a jsconfig.json file on the root of your project and paste this(if you use src as the starting point for your absolute imports
{
"compilerOptions": {
"baseUrl": "./src"
}
}

Travis CI fails to unzip gradle 1.11 with gradle wrapper

Since today, the builds of one of my projects fail on Travis CI, because of issues in unzipping gradle 1.11. This applies to newer builds as well as old builds that were executed fine days ago. gradlew assemble works fine on my local machine, it only fails on Travis CI. The output of the build is the following:
Using worker: worker-linux-6-2.bb.travis-ci.org:travis-linux-9
$ git clone --depth=50 --branch=master git://github.com/lenhard/pete.git lenhard/pete
Cloning into 'lenhard/pete'...
remote: Counting objects: 779, done.
remote: Compressing objects: 100% (567/567), done.
remote: Total 779 (delta 325), reused 571 (delta 134)
Receiving objects: 100% (779/779), 4.20 MiB | 0 bytes/s, done.
Resolving deltas: 100% (325/325), done.
Checking connectivity... done.
$ cd lenhard/pete
$ git checkout -qf 5bef29676d981c7de80517950cbb9b1bb85bba00
$ jdk_switcher use oraclejdk8
Switching to Oracle JDK8 (java-8-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-8-oracle
update-alternatives: error: no alternatives for apt.
$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b128)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)
$ javac -version
javac 1.8.0
before_install
$ chmod +x gradlew
$ ./gradlew assemble
Downloading http://services.gradle.org/distributions/gradle-1.11-bin.zip
Unzipping /home/travis/.gradle/wrapper/dists/gradle-1.11-bin/4h5v8877arc3jhuqbm3osbr7o7/gradle-1.11-bin.zip to /home/travis/.gradle/wrapper/dists/gradle-1.11-bin/4h5v8877arc3jhuqbm3osbr7o7
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:220)
at java.util.zip.ZipFile.<init>(ZipFile.java:150)
at java.util.zip.ZipFile.<init>(ZipFile.java:164)
at org.gradle.wrapper.Install.unzip(Install.java:148)
at org.gradle.wrapper.Install.createDist(Install.java:65)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47)
Travis tries to repeat gradlew assemble two more times, but fails ultimately. My .travis.yml is really simple:
language: java
jdk:
- oraclejdk8
before_install:
- chmod a+x gradlew
Where could this issue come from? When accessing http://services.gradle.org/distributions/gradle-1.11-bin.zip from my machine, I get a proper distribution that can be unzipped and works. Could this be related to the fact that I use JDK 1.8?
The issue was neither caused by Travis CI, nor by the project configuration. Instead, it seems that the gradle wrapper had problems following redirects for a new host. This came from the enablement of https downloads for the wrapper at gradle.org. The problem was fixed on their side and everything is back to normal now.
More info on this problem can be found in the gradle forums.

Git (Windows) - cannot create file on clone. Works as Superuser

I'm using Windows 8, 64bit - I recently installed Git to use it on this computer. However, it is not possible to clone any repository. It exits with the message:
$ git clone ssh://me#some.address.com/some/git/repository.git
Cloning into 'repository'...
error: Unable to create c:/Users/Danyel/workspace/repository/.git/HEAD
When I open cmd as Administrator and try the same command, it succeeds (cmd as normal user fails just like with Git Bash):
C:\Users\Danyel\workspace>git clone ssh://me#some.address.com/some/git/repository.git
Cloning into 'repository'...
remote: Counting objects: 221, done.
remote: Compressing objects: 100% (195/195), done.
remote: Total 221 (delta 34), reused 167 (delta 15)
Receiving objects: 100% (221/221), 9.23 MiB | 1.38 MiB/s, done.
Resolving deltas: 100% (34/34), done.
Checking connectivity... done
I'm using this version of Git: Git-1.8.4-preview20130916
Any help or clues are welcome! I have checked for the permissions and have ownership in parent folders ("repository", ".git"). What else can it be??
Edit:
The GIT_TRACE option did not give any clue about it either:
$ GIT_TRACE=2 git clone ssh://me#some.address.com/some/git/repository.git
trace: built-in: git 'clone' 'ssh://me#some.address.com/some/git/repository.git'
Cloning into 'repository'...
error: Unable to create c:/Users/Danyel/Desktop/repository/.git/HEAD
As illustrated in this thread, that kind of error message only happens when one of the parent folders is a symlink.
Check if you can clone it in another path (C:\ or C:/Users/Danyel).
But I suspect that Desktop\workspace is a symlink, and as such, not very compatible with a cloned repo path (because that would un-symlink that path, which might not be compatible with other apps/process using that same path).
The only other instance of that issue is related to a path-length limit.

git flow installer fails to install shFlags on the Mac OS X 10.8.3

Tried this several times including nuking the previous download and manually getting the submodule. Does anyone have a workaround?
SilverFir-2:SRC mike$ sudo ./git-flow-installer
### gitflow no-make installer ###
Installing git-flow to /usr/local/bin
Cloning repo from GitHub to gitflow
Cloning into 'gitflow'...
remote: Counting objects: 1407, done.
remote: Compressing objects: 100% (602/602), done.
remote: Total 1407 (delta 893), reused 1285 (delta 790)
Receiving objects: 100% (1407/1407), 358.18 KiB | 121 KiB/s, done.
Resolving deltas: 100% (893/893), done.
Updating submodules
Submodule 'shFlags' (git://github.com/nvie/shFlags.git) registered for path 'shFlags'
Cloning into 'shFlags'...
fatal: unable to connect to github.com:
github.com[0: 204.232.175.90]: errno=Operation timed out
Clone of 'git://github.com/nvie/shFlags.git' into submodule path 'shFlags' failed
install: gitflow/git-flow -> /usr/local/bin/git-flow
install: gitflow/git-flow-init -> /usr/local/bin/git-flow-init
install: gitflow/git-flow-feature -> /usr/local/bin/git-flow-feature
install: gitflow/git-flow-hotfix -> /usr/local/bin/git-flow-hotfix
install: gitflow/git-flow-release -> /usr/local/bin/git-flow-release
install: gitflow/git-flow-support -> /usr/local/bin/git-flow-support
install: gitflow/git-flow-version -> /usr/local/bin/git-flow-version
install: gitflow/gitflow-common -> /usr/local/bin/gitflow-common
install: gitflow/gitflow-shFlags: No such file or directory
SilverFir-2:SRC mike$
It looks like it may just be a temporary connection issue (though it's unusual that you were able to manually get the submodule but the script couldn't do it). The make-less installer appeared to work fine on my Mac OS 10.8.3 system. The make-less installer isn't doing much, you can run the steps yourself to install it-
git clone https://github.com/nvie/gitflow.git
cd gitflow
git submodule init
git submodule update
sudo make install

Resources