Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

gosrc: Parsing file field of go-source meta tag does not implement spec fully. #385

Closed
@dmitshur

Description

@dmitshur

The documentation of go-source meta tag, https://github.com/golang/gddo/wiki/Source-Code-Links, states:

The file field is a URL template for a link to a line in a source file. The following substitutions are made in the file template:

{file} - The name of the file
{line} - The decimal line number.

However, the actual implementation does not implement that behavior fully and correctly.

Instead, it makes a number of assumptions about what the file field URL template will look like, and fails to do what's expected given the spec above if any of the assumptions are not met.

Put simply, the file field URL template is expected to have {file} in the first part, followed by a # character, followed by optional single {line} in the second part.

I've tried to document the exact consequences of the current implementation here:

https://github.com/golang/gddo/wiki/Source-Code-Links/_compare/c3ec2f0e81d8689d50447495bf06f0c813cd766f...f5b0915990618ae8a8cda98fa47f184a5f3e1c6a

It's not pretty, and it's not simple. 😧

When I tried to have a file field URL template that had both {file} and {line} come after the first #, the file field was effectively ignored. /cc @slimsag

The file field URL template should be implemented as described in the spec and then the limitations section should be removed from the wiki.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions