In my project, my files all need to have Apache-2.0 license headers if possible. This is done with a comment block. My SQL queries are in separate files and then embedded like
//go:embed select.sql
var selectQuery string
and then the select query file looks like
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
-- http://www.apache.org/licenses/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
SELECT * FROM my_table
Notice the URL. If you try to run this with a NamedQuery, it'll tell you that it cannot find the parameter with the name "", because it's trying to replace the : from the license URL.
Comment blocks should not be processed for any kind of parameter replacement.
In my project, my files all need to have Apache-2.0 license headers if possible. This is done with a comment block. My SQL queries are in separate files and then embedded like
and then the select query file looks like
Notice the URL. If you try to run this with a NamedQuery, it'll tell you that it cannot find the parameter with the name "", because it's trying to replace the
:
from the license URL.Comment blocks should not be processed for any kind of parameter replacement.