This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2021/10/04 08:03:16 ...s/context/context.go:195:HTML() [E] Render failed: template: repo/diff/csv_diff:3:15: executing "repo/diff/csv_diff" at <call .root.CreateCsvDiff .file .root.BaseCommit .root.HeadCommit>: error calling call: runtime error: invalid memory address or nil pointer dereference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal data class Position(val name: String) { | |
constructor(file: Int, rank: Int) : this("${(file + 'A'.toInt()).toChar()}${rank + 1}") | |
val file: Int = name.validateAndTransform { it[0] - 'A' } | |
val rank: Int = name.validateAndTransform { it[1].toString().toInt() - 1 } | |
private fun <T> String.validateAndTransform(trasformer: (String) -> T): T = | |
if (Regex("""^[A-H][1-8]$""") matches this) | |
trasformer(this) |