Install exp/html in Go - installation

It looks like Go doesn't support HTML web parsing tools/packages yet, despite it already providing XML scraping via encoding/xml. So how can I install exp/html package in Go?
As far as I know, all the answers, at least I stumbled upon on the Web with 10 minutes worth of searching, didn't return the correct answer; when I tried to run those, I got the error cannot find package XXX in YYY or no Go source files in XXX.
So as of now, can I install it without re-compling and setting the whole Go environment from scratch? Or am I missing something?
I'm on OS X 10.8 and run Go version 1.1, which I installed from OS X package installer.
For your information, these code didn't make it.
go get code.google.com/p/go/src/pkg/exp/html
go get code.google.com/p/go.exp/inotify
Thanks.

I just tried:
go get code.google.com/p/go.net/html
and it seemed to work.
I have a feeling it's been moved from the exp library to the new net library.
EDIT: Documentation & browseable repo.

With go 1.4 (November 9th, 2014), you will have to type:
go get golang.org/x/net/html
See:
"New Import paths for Go sub-repositories".
"Go 1.4 subrepo renaming".

Related

Terraform Provider-specify version of SDK to pull / Cannot use validation.StringInSlice type schema.SchemaValidateFunc as type SchemaValidateDiagFunc

Due to this problem it looks like for providers you have to get a current version of the SDK (2.4.4 at time of post). This post has a lot of info on how to import a specific version of a package but surely every single provider writer isn't manually pulling the most recent version of the SDK (or are they)?
I'm new to Go/Terraform so maybe I'm missing something obvious but the providers I've found (including the official example) have something like:
import(
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
The current version is not 2 - it is 2.4.4. Now I know those are local paths but what confuses me is when I run something like go get it goes and pulls those down for me. I tried doing:
"github.com/hashicorp/terraform-plugin-sdk/v2.4.4/helper/schema"
but go get very much doesn't like that. How is go get finding those package versions? Is there an import syntax that just gets me the latest build or allows me more granularity? I haven't found a good way to tell what version of the SDK I have after running go get but based on this error message:
it looks like I have 2.0 because that error is, as I understand it, fixed in newer versions of the SDK.
I figured it out. The behavior is controlled by the go.mod file.
In there you'll find:
require (
github.com/hashicorp/terraform-plugin-sdk v1.14.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.1
As mentioned by #JimB the v2 is the major version for the plugin. v2.0.1 are GitHub tags. Changing this to v2.4.4 obtains the desired behavior.

Check if a new version of go based binary is available using go get

I am a little bit new to Go, specifically go get mechanism to download single binaries (CLI apps). Some cool projects in github allow you to download cli apps using go get. How can I check that binary that I installed is outdated? I am looking for something like debian based apt update that checks for newest package versions without installing them.
As an example. Let's say that I installed lazygit using go get github.com/jesseduffield/lazygit. And after a while a new version was released in github . Is it possible to check new version of binary using go get?
I checked the help and found the -u flag. Use go get -u github.com/jesseduffield/lazygit to update the tool.
None of this is speicific to the GitHub.

Go Wants to Import Package From Comment [duplicate]

New Go programmer here -- apologies if this is well worn territory, but my google searching hasn't turned up the answer I'm looking for.
Short Version: Can I, as a programmer external to the core Go project, force my packages to be imported with a specific name. If so, how?
Long Version: I recently tried to install the bcrypt package from the following GitHub repository, with the following go get
go get github.com/golang/crypto
The package downloaded correctly into my workspace, but when I tried to import it, I got the following error
$ go run main.go main.go:10:2: code in directory /path/to/go/src/github.com/golang/crypto/bcrypt expects import "golang.org/x/crypto/bcrypt"
i.e. something told Go this package was supposed to be imported with golang.org/x/crypto/bcrypt. This tipped me off that what I actually wanted was
go get golang.org/x/crypto/bcrypt
I'd like to do something similar in my own packages — is this functionality built into Go packaging? Or are the authors of crypto/bcrypt doing something at runtime to detect and reject invalid package import names?
Yes it's built in, I can't seem to find the implementation document (it's a relatively new feature in 1.5 or 1.6) however the syntax is:
package name // import "your-custom-path"
Example: https://github.com/golang/crypto/blob/master/bcrypt/bcrypt.go#L7
// edit
The design document for this feature is https://docs.google.com/document/d/1jVFkZTcYbNLaTxXD9OcGfn7vYv5hWtPx9--lTx1gPMs/edit
// edit
#JimB pointed out to https://golang.org/cmd/go/#hdr-Import_path_checking, and in the go1.4 release notes: https://golang.org/doc/go1.4#canonicalimports

Warning message when installing devtools

When I try to install devtools in Rstudio 3.2.3 (Windows 10) using the command install.packages("devtools"), I get the following message:
warning in install.packages :
'lib = "c:/Program Files/R/R-3.2.3//library"' is not writable
I'm a newby and I've been hunting for solutions but so far am coming up empty. I would appreciate any advice that might get me through this step. Thanks.
I stumbled upon the same issue earlier. This "problem" arises when you try to install a library for the first time and R does not have a a dedicated library for it yet.
Two pop-up should appear one after the other when you try to install a package like:
install.packages("ggplot2")
The questions are the following:
Would you like to use a personal library instead?
Would you like to create a personal library 'C:\Users\bartlein\Documents/R/win-library/3.2' to install packages into?
Answer yes to both questions and you should be fine.
The ressources I used came from here.

Why IntelliJ Idea cannot find location of GO SDK?

I downloaded go1.4.darwin-amd64-osx10.8.tar.gz and extract it on my local directory.
Based on what Installing to a custom location says I added GOROOT in env variable.
Based on what Test your installation says I created a go file.
I finally ran it and I got expected result as following screenshot.
I actually have IntelliJ v.14 however, based on this article I installed Go Language (golang.org) version 0.9.15.3 in my IntelliJ Idea.
I created a Go project and during creation it asked me to add GO SDK. I gave it ~/Desktop/go/sdk however it wasn't able to recognise it. I got this error in Event Log:
14:03:02 IllegalArgumentException: Argument for #NotNull parameter
'virtualFile' of
com/intellij/openapi/projectRoots/impl/ProjectRootContainerImpl.addRoot
must not be null
Any idea how IntelliJ Idea is able to recognize it would be appreciated. Thanks.
Please consider using one of the alpha releases for 0.9.16. I believe that alpha7 could be the more stable one rather than alpha9. You can get them from GitHub releases
The v1.0.0-alpha0 branch is, as the name implies, an alpha release and it's in the early stages of development, that's why there's no release done yet for it as well.
P.S. I'm one of the contributors to the plugin.
Does not allow to use SDK placed in /usr/local/go (perfectly valid and recent SDK) under Mac Yosemite.
Google App Engine does not recognise last valid GAE GO SDK either.
~Desktop/go/sdk doesn't seems a valid path (as it refers to the homedir of the 'Desktop' user): ~/Desktop/go/sdk should work better.
As long as you see in that ~/Desktop/go/sdk folders the subfolders 'api', 'bin', 'blog', ..., that should be the right one for the GO SDK expected by the "golang support plugin".
Some issues exist with that plugin and IntelliJ 14: issues 1169, PR 1172 (fixed for for 1.0.0-alpha).
The other approach is to recompile and install that plugin.
The end result of specifying the Go SDK path should look like:

Resources