Skip to content

Conversation

XuehaiPan
Copy link
Contributor

Add a nice separator after the license header if the template has no bottom.

This separates the license and the code comments with =s.

tmpl.go Outdated
Comment on lines 101 to 124
} else if lines > 3 {
fmt.Fprintln(&out, mid + strings.Repeat("=", 80 - len(mid)))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separator is added only when the license block has more than 3 lines.

@XuehaiPan XuehaiPan force-pushed the add-separator branch 5 times, most recently from 789b82e to 9d0b267 Compare June 5, 2025 12:39
@flwyd
Copy link
Contributor

flwyd commented Jul 7, 2025

Thanks for your interest in addlicense. The tool already adds a blank line between the end of the license header comment and the first line of the file's existing content. Is there a reason this blank line is insufficient visual separation?

Adding this separator line automatically may be rather disruptive: while many projects use such a line, lots of others don't. In particular, projects which have already been using addlicense won't have any such lines in their code base, so upgrading to a release which does so automatically will produce visually different file headers.

@XuehaiPan
Copy link
Contributor Author

Hi @flwyd, thanks for the valuable comments.

The tool already adds a blank line between the end of the license header comment and the first line of the file's existing content. Is there a reason this blank line is insufficient visual separation?

For the header that has multiple paragraphs (e.g., Apache License), the paragraphs are separated with a black line, which is the same separator as the following user code. That is hard to distinguish the start of the true user code.

# Copyright XXX. All Rights Reserved.
#
# 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.

# User code: This file is used to ...
# User code: This file is used to ...
# User code: This file is used to ...

This PR only adds a visual separation line to the header if it has more than three lines.

Another use case is that the file has multiple license headers to respect the copyright of the original authors (e.g., more than one Apache License with different affiliations).

# Copyright XXX. All Rights Reserved.
#
# 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.
# ==============================================================================
# This file is adopted from: https://github.com/YYY/ZZZ.git
# ==============================================================================
# Copyright YYY. All Rights Reserved.
#
# 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.
# ==============================================================================

# User code: This file is used to ...
# User code: This file is used to ...
# User code: This file is used to ...

@XuehaiPan XuehaiPan force-pushed the add-separator branch 2 times, most recently from 470de8b to fe79e8d Compare July 28, 2025 05:12
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

Successfully merging this pull request may close these issues.

2 participants