github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/hammers/importpath.go (about)

     1  // +build ignore
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  
     8  	"golang.org/x/tools/imports"
     9  )
    10  
    11  func main() {
    12  	iface := "http.Handler"
    13  	src := "package hack; var i " + iface // HL
    14  	fmt.Println(src, "\n---")
    15  
    16  	imp, _ := imports.Process("", []byte(src), nil) // HL
    17  	// ignoring errors throughout this presentation
    18  	fmt.Println(string(imp))
    19  }