How to install the go package: gencodec? - go

Basically, the title of the question. I am new to developing with the Go programming language, and I am getting this error when trying to install this specific package: gencodec
go install gencodec#latest: malformed module path "gencodec": missing dot in first path element
This is pretty much the only documentation I could find on it, and it doesn't provide a tutorial on how to install it.
Click here for the docs
Is installing packages via go similar to using npm? I come from a javascript background so I am not entirely sure if I am even doing it correctly.
Thanks!

I understand you want to create a type structure.
I read in the documentation you provided, you will need to build the gencode binary. gencode repository
Try downloading the gencode repository content, into the execute go build folder, then you will have a binary gencode ... after that run gencodec -type MyType -formats json, yaml, toml -out mytype_json.go

Related

Can 'go install' be made to work for executables with different names from the git repo?

Go has a nice feature where you can go install <x> and it will download, build and install a binary.
For example, on my local windows PC, go install github.com/goreleaser/goreleaser will find the latest release for goreleaser, download, build and install it to my local binaries path.
I am working on a project where we would like to enable go install, but encounter a problem if the github repo name does not match the executable name. The GitHub CLI itself runs into the exact same problem:
Example:
go install github.com/cli/cli#latest
go: downloading github.com/cli/cli v1.14.0
go: github.com/cli/cli#latest: module github.com/cli/cli#latest found (v1.14.0), but does not contain package github.com/cli/cli
Is there a way to resolve this?
Update: I worked out that I could directly reference the package via it's sub directory. In my particular instance this works: go install github.com/OctopusDeploy/cli/cmd/octopus#latest
This is a bit unpleasant, but works correctly. It doesn't work for the github CLI because their go.mod has a replace directive in it :-(
Question: Can this be made nicer? Is there a way to put some sort of alias or configuration file so that go install github.com/OctopusDeploy/cli#latest can be used instead of go install github.com/OctopusDeploy/cli/cmd/octopus#latest ?
Can this be made nicer? Is there a way to put some sort of alias or configuration file so that go install github.com/OctopusDeploy/cli#latest can be used instead of go install github.com/OctopusDeploy/cli/cmd/octopus#latest ?
No. Dead simple.

Issue in installing a go package

So,I recently started following a video tutorial and i am fairly new to golang and tried installing the forked version of bolt db using
$ go get go.etcd.io/bbolt/...
Note : I want to use this specific version
but i am getting an error which says
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd#latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'
I read a few GitHub issues which say that go get is deprecated so how do I resolve this ?
I also tried few other things such as
go install go.etcd.io/bbolt/...
Go modules are today's standard. Especially if you are new to Go; do not spend time on material that do not use (and teach) them.
Run go mod init yourproject
in your project repository root directory. This will create go.mod file.
Once you have that you can either:
import go.etcd.io/bbolt in source code and then run go mod tidy. Go tool will find and add module to your dependencies (go.mod file). This is described in Getting started tutorial.
run go get go.etcd.io/bbolt directly, that will update dependencies too.
Using Go Modules series explains workflow in detail and will be helpful when converting commands from an outdated material.

Installing Julia packages using a .toml file?

I am totally new to Julia!
I would like to install a large number of packages for a project I'm joining.
The project comes with a "Project.toml" file
It seems like there should be a nice way to install all the packages I need for the project, perhaps using the Project.toml file
However, I have not yet found any site that indicates how I might be able to do this.
Could anyone please let me know if what I am doing is possible, and if so, point me to a reference that would show how?
If your Project.toml is located in a folder, like myproject/Project.toml, you can simply start Julia with julia --project=/path/to/myproject, and it will automatically detect the Project.toml file in myproject.
The first time you activate this project, in the REPL, you can switch to Pkg mode by typing ], and type the command instantiate. This will cause the package manager to download and install all of the packages listed in Project.toml and their dependencies.
Another way to switch between projects during interactive use is to run activate /path/to/myproject in Pkg-mode in the REPL.
How to install julia packages from a Project.toml
First, you will have navigate to the folder containing your Project.toml.
cd ../your-folder-containing-the-project.toml-file
in your terminal:
julia --project=.
]
instantiate
or
julia --project=. -e 'using Pkg; Pkg.instantiate()
The other answers went already to the point, but I want to add another important aspect.
If this project comes "only" with a Project.toml file, you will be able to install "sone version" of these packages, eventualy the Project.toml may also give you a range of versions known to work with the project you have been given.
But if this project comes also with a Manifest.toml file you will be able to recreate on your pc the exact environment, will all the exact versions of all dependent packages recursivelly, of the guy that passed you the project, using the ways desctibed in detail in the other answers (e.g. ] activate [folder]; instantiate).

Difficulty installing go buffalo using go mod on windows

I am very new to golang. I am trying to work with the gomod. Trying to explore the go buffalo framework. But finding a bit of difficulty in installing that.
What I have done:
I saw that go get is nomore supported for buffalo and so switched to go modules.
Created a module by go mod init github.com/webbuffalotest
Fetched go get -v github.com/gobuffalo/buffalo (on the same directory where I have go.mod file)
Fetched go get -v github.com/mattn/go-sqlite3 (on the same directory where I have go.mod file)
go install github.com/gobuffalo/buffalo
I was expecting a buffalo.exe inside %GOPATH%/bin so that I can add it to my path but didn't find one.
My question is what's wrong? Is the exe not installed or it's somewhere else because of go mod. Any help will be highly appreciated.
I am using windows 10. I am not willing to install package managers as scoop or choco to install buffalo. Thanks for your patience :)
Edited:
Also tried setting set GO111MODULE=on but of no use.
Solved:
My bad, I should have used go install github.com/gobuffalo/buffalo/buffalo instead of go install github.com/gobuffalo/buffalo
github.com/gobuffalo/buffalo is a library; the corresponding binary is (aptly-named) github.com/gobuffalo/buffalo/buffalo.
The go install command you ran should have warned you about that, but didn't because go install used to also be used to cache compiled libraries (it no longer does that in module mode).
I've filed https://golang.org/issue/46912 to add a diagnostic.

Including date and time in Tex File

The latex file is giving the following error:
! LaTeX Error: File `datetime.sty' not found.
Here is the Latex code: \usepackage{datetime}
Am I missing something?
I am using Debian 3.1 Linux Machine.
I don't use Debian myself, but if I look it up, Debian contains it in the package 'texlive-latex-extra'. If you installed LaTeX via the packet-manager of debian (I think so) the command 'apt-get install texlive-latex-extra' executed as root should install you the needed file. Alternatively you can use a graphical package-manager to install the package.
If your LaTeX Distribution does not load the package automatically, you can try to install it manually according to the readme file here: http://www.ctan.org/pub/tex-archive/macros/latex/contrib/datetime/ Edit: http://www.ctan.org/pkg/datetime
Yes, you are missing the datetime.sty file; you are probably missing the whole package too. What system are you using for managing your (La)TeX installation ? If you tell us you may get more specific advice than I can give.
You need to get the datetime package from CTAN or one of its mirrors and install it into your local texmf tree. Your LaTeX manager will do this for you. You may also be able to configure your LaTeX manager to automatically download and install packages the first time they are requested.

Resources