Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import list at /importer/ doesn't work with Go tip #1090

Closed
bradfitz opened this issue Apr 17, 2018 · 2 comments
Closed

Import list at /importer/ doesn't work with Go tip #1090

bradfitz opened this issue Apr 17, 2018 · 2 comments

Comments

@bradfitz
Copy link
Contributor

The URL /importer/ works when camlistored is build with Go 1.10, but I get a template error about missing $base when I compile with Go tip.

Investigate.

Maybe we're using template wrong, or maybe it's an upstream Go bug.

/cc @mpl

@bradfitz
Copy link
Contributor Author

The error is:

Error executing template "importersRootPage": template: root:25:22: executing "importersRootBody" at <.Host.ImporterBaseUR...>: undefined variable: $base

The html/template code is:

var tmpl = template.Must(template.New("root").Funcs(map[string]interface{}{
        "bloblink": func(br blob.Ref) string {
                panic("should be overridden; this one won't be called")
        },
}).Parse(`                                                                                                                                              
{{define "pageTop"}}                                                                                                                                    
<html>                                                                                                                                                  
<head>                                                                                                                                                  
   <title>{{.Title}}</title>                                                                                                                            
</head>                                                                                                                                                 
<body>                                                                                                                                                  
   <h1>{{.Title}}</h1>                                                                                                                                  
{{end}}                                                                                                                                                 
                                                                                                                                                        
{{define "pageBottom"}}                                                                                                                                 
</body>                                                                                                                                                 
</html>                                                                                                                                                 
{{end}}                                                                                                                                                 
                                                                                                                                                        
                                                                                                                                                        
{{define "importersRootPage"}}                                                                                                                          
  {{template "pageTop" .}}                                                                                                                              
  {{template "importersRootBody" .Body}}                                                                                                                
  {{template "pageBottom"}}                                                                                                                             
{{end}}                                                                                                                                                 
                                                                                                                                                        
{{define "importersRootBody"}}                                                                                                                          
   <ul>                                                                                                                                                 
      {{$base := .Host.ImporterBaseURL}}                                                                                                                
      {{range .Importers}}                                                                                                                              
         <li><a href="{{$base}}{{.Name}}">{{.Name}}</a></li>                                                                                            
      {{end}}                                                                                                                                           
   </ul>                                                                                                                                                
{{end}}                                                                                                                                                 

....
`)

I see @mvdan added https://go-review.googlesource.com/84480 ("text/template: add variable assignments") on Dec 2017 for Go 1.11 (tip), but it seems we were already using variable assignments? I'm confused.

camlistorebot pushed a commit that referenced this issue Apr 17, 2018
Updates #1090

Change-Id: I16ee3cfd49ba9af2b98cdef470932ca000d768dc
@bradfitz
Copy link
Contributor Author

Duplicate of golang/go#24791

Already fixed upstream. My Go binary was a bit too old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant