kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/go/util/schema/tickets/tickets.go (about) 1 /* 2 * Copyright 2017 The Kythe Authors. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // Package tickets defines functions for manipulating Kythe tickets. 18 package tickets // import "kythe.io/kythe/go/util/schema/tickets" 19 20 import "kythe.io/kythe/go/util/kytheuri" 21 22 // AnchorFile constructs the canonical file ticket corresponding to a given 23 // anchor ticket. It is an error only if anchofTicket is invalid. 24 func AnchorFile(anchorTicket string) (string, error) { 25 // Use ParseRaw to avoid the expense of unescaping, which we don't need. 26 r, err := kytheuri.ParseRaw(anchorTicket) 27 if err != nil { 28 return "", err 29 } 30 // See http://www.kythe.io/docs/schema/#anchor for vname rules. 31 r.URI.Signature = "" 32 r.URI.Language = "" 33 return r.String(), nil 34 }